-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.sh
executable file
·52 lines (40 loc) · 1.07 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
47
48
49
50
51
52
#!/bin/bash
# need to document
HERE=$(pwd)
echo $HOME
echo "Setup dotfiles in $HOME"
FILES_TO_LINK=('.profile' '.bash_aliases' '.bashrc' '.git-prompt.sh' '.inputrc' '.tmux.conf' '.remarkrc.json')
ELEMENTS=${#FILES_TO_LINK[@]}
for (( i=0;i<$ELEMENTS;i++)); do
FILE=${FILES_TO_LINK[${i}]}
SRC="$HERE/$FILE"
DEST="$HOME/$FILE"
echo "-> current file: $SRC -> $DEST"
if [ ! -L "$DEST" ]; then
echo "--> no symlink for $SRC, back up and link"
if [ -f "$DEST" ]; then
mv "$DEST" "$DEST"-old
fi
ln -s "$SRC" "$DEST"
else
echo "--> link exists for file $SRC, no action required"
fi
done
TEMPLATES_TO_COPY=('.gitconfig')
ELEMENTS=${#TEMPLATES_TO_COPY[@]}
echo "template array count $ELEMENTS"
for (( i=0;i<$ELEMENTS;i++)); do
FILE=${TEMPLATES_TO_COPY[${i}]}
echo "current file: $HOME/$FILE"
if [ ! -f "$HOME/$FILE" ]; then
mv "$HOME/$FILE" "$HOME/$FILE-old"
cp "$HERE/$FILE" "$HOME/$FILE"
else
echo 'target exists'
fi
done
if [ -d ~/.config/nvim -a -L ~/.config/nvim ]; then
echo ".config/nvim exists as dir and link"
else
ln -s $HERE/nvim ~/.config/nvim
fi