-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·49 lines (40 loc) · 1.4 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Installation dir
if [[ ! -z $1 ]]; then
if [[ -d $1 ]]; then
DIR=$1
else
echo "$1 is not a directory!"
exit 1
fi
else
DIR=$(dirname $(readlink -f $0))
if [[ $DIR = $HOME* ]]; then DIR=~${DIR#$HOME}; fi
fi
echo "Sourcing dotfiles from $DIR"
# Do the install
[[ -e ~/.bashrc ]] || touch ~/.bashrc
if ! grep -q 'Source dotfiles' ~/.bashrc; then
echo -e "#Source dotfiles\nsource $DIR/bashrc\n" | cat - ~/.bashrc >_tmp && mv _tmp ~/.bashrc
echo "Installed in .bashrc"
fi
[[ -e ~/.bash_profile ]] || touch ~/.bash_profile
if ! grep -q 'Source dotfiles' ~/.bash_profile; then
echo -e "# Source dotfiles\nsource $DIR/bash_profile\n" | cat - ~/.bash_profile >_tmp && mv _tmp ~/.bash_profile
echo "Installed in .bash_profile"
fi
[[ -e ~/.vimrc ]] || touch ~/.vimrc
if ! grep -q 'Source dotfiles' ~/.vimrc; then
echo -e "\" Source dotfiles\nsource $DIR/vimrc\n" | cat - ~/.vimrc >_tmp && mv _tmp ~/.vimrc
echo "Installed in .vimrc"
fi
[[ -e ~/.gitconfig ]] || touch ~/.gitconfig
if ! grep -q 'Source dotfiles' ~/.gitconfig; then
echo -e "# Source dotfiles\n[include]\npath=$DIR/gitconfig\n" | cat - ~/.gitconfig >_tmp && mv _tmp ~/.gitconfig
echo "Installed in .gitconfig"
fi
[[ -e ~/.inputrc ]] || touch ~/.inputrc
if ! grep -q 'Source dotfiles' ~/.inputrc; then
echo -e "# Source dotfiles\n\$include $DIR/inputrc\n" | cat - ~/.inputrc >_tmp && mv _tmp ~/.inputrc
echo "Installed in .inputrc"
fi