-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·46 lines (40 loc) · 1.22 KB
/
setup.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
#!/bin/bash
FILES=(.bash_aliases .bashrc .emacs.d .environment .git-completion.bash .gitconfig .globalgitignore .profile .screenrc useful)
DIRECTORIES=(.ssh) # TODO: symlink files from within directories.
for filename in ${FILES[@]}
do
src=${HOME}/${filename}
dst="$HOME/.configs/$filename"
# Delete file if it exists.
if [ -e $src ]; then
if [[ -L $src && $(readlink $src) == $dst ]]; then
# If the symlink is already set up, don't have to do anything!
continue
elif [ -d $src ]; then
rm -i -r $src
else
rm -i $src
fi
fi
# Symlink to files in git repo
ln -s $dst $src
done
# Add bin scripts to bin
if [ ! -e $HOME/bin ]; then
mkdir $HOME/bin
fi
for filepath in $HOME/.configs/bin/*
do
filename=$(basename $filepath)
destname=$(basename $filepath .sh)
chmod 770 $HOME/.configs/bin/$filename
if [[ ! (-L $HOME/bin/$destname && $(readlink $HOME/bin/$destname) == $HOME/.configs/bin/$filename) ]]; then
ln -s $HOME/.configs/bin/$filename $HOME/bin/$destname
fi
done
# Setup githooks
mkdir -p $HOME/.git_template/hooks
for hook in $HOME/.configs/githooks/*
do
cp -i $hook $HOME/.git_template/hooks/
done