-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·69 lines (61 loc) · 1.31 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
cd ~ || exit 1
[ -d .dotfiles ] || { echo Install in ~/.dotfiles; exit 1; }
pushd .dotfiles
git submodule init
git submodule update
popd
function install_file {
echo "#### $1"
TARGET=~/.$1
SOURCE=.dotfiles/$1
if ! [ -e $SOURCE ]
then
echo File not found $SOURCE
return
fi
if [ -h $TARGET ]
then
echo $TARGET is already a link. Removing.
rm -f $TARGET
fi
if [ -e $TARGET ]
then
echo $1 alsready exists!
if [ ! -f $TARGET -a ! -d $TARGET ]
then
echo $TARGET is neither a file or directory. Skipping...
return
fi
SAVED=$TARGET.dotfiles-orig
echo Saving actual $TARGET to $SAVED
mv $TARGET $SAVED
fi
echo Installing $SOURCE in $TARGET
ln -s $SOURCE $TARGET
echo "Done $1"
}
function save_bashrc_as_local {
if [ -e ~/.bashrc ]
then
if [ -e ~/.bashrc_local ]
then
echo Cannot save current .bashrc to .bashrc_local
echo .bahsrc will NOT be installed
return 1
else
echo Saving .basrc as .bashrc_local
mv ~/.bashrc ~/.bashrc_local
fi
fi
}
echo Installing dotfiles...
save_bashrc_as_local && install_file 'bashrc'
install_file 'bash'
install_file 'vimrc'
install_file 'vim'
install_file 'gitconfig'
install_file 'gitignore_global'
install_file 'pryrc'
install_file 'oh-my-zsh'
install_file 'zshrc'