-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_link.sh
executable file
·71 lines (59 loc) · 1.58 KB
/
make_link.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
70
71
#!/bin/zsh
# initialize CORP using hostname.sh
if [[ -e "exclusives/hostname.sh" ]]; then
source "exclusives/hostname.sh"
CORP="$HOSTNAME_ALIAS"
fi
# backup function to move existing config file
function backup {
FILE="$HOME/$1"
if [ ! -e "$FILE" ]; then
return
fi
DEST="$FILE"
NUM=0
while [ -e "$DEST" ]; do
if [ -L "$DEST" ]; then
rm "$DEST"
echo -e "$DEST is symlink; \e[1mremoved\e[0m"
break
fi
((NUM++))
DEST="$FILE.backup$NUM"
done
if [ -e "$FILE" ]; then
mv "$FILE" "$DEST"
echo -e "$FILE \e[1mis moved to\e[0m $DEST"
fi
}
echo "start making simlinks"
backup ".zshrc"
if [[ -e "exclusives/zshrc" && -n "$CORP" ]]; then
ln -s ~/.dotfiles/exclusives/zshrc ~/.zshrc
echo -e " \e[1mUse exclusive zshrc\e[0m"
else
ln -s ~/.dotfiles/zshrc ~/.zshrc
fi
backup ".vimrc"
if [[ -e "exclusives/vimrc" && -n "$CORP" ]]; then
ln -s ~/.dotfiles/exclusives/vimrc ~/.vimrc
echo -e " \e[1mUse exclusive vimrc\e[0m"
else
ln -s ~/.dotfiles/vimrc ~/.vimrc
fi
backup ".hgrc"
if [[ -e "exclusives/hgrc" && -n "$CORP" ]]; then
ln -s ~/.dotfiles/exclusives/hgrc ~/.hgrc
fi
backup ".bash_profile"
ln -s ~/.dotfiles/bash_profile ~/.bash_profile
backup ".gitconfig"
ln -s ~/.dotfiles/gitconfig ~/.gitconfig
backup ".gitexclude"
ln -s ~/.dotfiles/gitexclude ~/.gitexclude
backup ".ssh/config"
ln -s ~/.dotfiles/sshconfig ~/.ssh/config
backup ".tmux.conf"
ln -s ~/.dotfiles/tmux.conf ~/.tmux.conf
backup ".editorconfig"
ln -s ~/.dotfiles/editorconfig ~/.editorconfig