forked from sirajissani/dotconfone
-
Notifications
You must be signed in to change notification settings - Fork 2
/
link.sh
executable file
·53 lines (46 loc) · 1.08 KB
/
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
#!/bin/bash
# USAGE
#
# `./link.sh`
#
# Links the user's dot-confs with the managed versions.
# Run as root to apply settings to root user-account.
#
#
# DESCRIPTION
#
# The following dot-confs are currently managed
#
# * `.vimrc`
# * `.vim/`
# * `.bashrc`
# * `.bash_aliases`
#
# The existing files, if not already linked are copied as
# `file.bak` and then links are created to the managed
# versions contained in this package directory.
#
#
# SEE ALSO
#
# `unlink.sh`
#
function backup_and_link() {
if [ ! -e $1 ] || [ ! -h $1 ]; then
echo " Backing up $1 --> $1.bak"
mv $1 $1.bak
echo " Linking $1 --> $2"
ln -s $2 $1
else
echo " Skipping $1"
fi
}
if [ ! -e "$HOME" ]; then
exit -1;
fi
DCO_PATH=$PWD/$(dirname $0)
backup_and_link $HOME/.vimrc $DCO_PATH/packages/vim/.vimrc
backup_and_link $HOME/.vim $DCO_PATH/packages/vim/.vim
backup_and_link $HOME/.bashrc $DCO_PATH/packages/bash/.bashrc
backup_and_link $HOME/.bash_aliases $DCO_PATH/packages/bash/.bash_aliases
backup_and_link $HOME/.config/nvim $DCO_PATH/packages/nvim