-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-dotfiles
executable file
·53 lines (41 loc) · 1.01 KB
/
install-dotfiles
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
#!/bin/sh
set -e
if [ "$(basename "$0")" != install-dotfiles ]; then
if ! which git >/dev/null; then
echo "Please install git first" 1>&2
exit 1
fi
if [ ! -d "$HOME/.dotfiles" ]; then
echo "Downloading dotfiles..."
git clone "https://github.com/nickmeharry/dotfiles.git" "$HOME/.dotfiles"
fi
cd
exec "$HOME/.dotfiles/install-dotfiles"
fi
dotfiles="
emacs.d
gitconfig
gitignore
hgrc
ackrc
pylintrc
zshrc
zprompt
zsh.d
tmux.conf
"
dotfiles_dir=".dotfiles"
cd $HOME
for df in $dotfiles; do
source="$dotfiles_dir/$df"
target=".$df"
if [ $target != "$(basename $target)" -a ! -e "$(dirname $target)" ]; then
echo "Creating directories \"$(dirname $target)\""
mkdir -p "$(dirname $target)"
fi
if [ ! -L $target -o "$(readlink $target)" != "$source" ]; then
[ -e $target -o -L $target ] && rm $target
echo "Linking $source to $target"
ln -s $source $target
fi
done