-
Notifications
You must be signed in to change notification settings - Fork 0
/
link.sh
executable file
·41 lines (34 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
#!/usr/bin/env bash
dir=~/dotfiles # dotfiles directory
olddir=~/dotfiles_old # old dotfiles backup directory
# list of files/dirs to symlink to in ~
files="lein emacs.d bash_custom gitconfig"
# list of files/dirs to symlink to in ~/.config
configs="flake8 git"
echo "Using $olddir for dotfiles backup"
mkdir -p $olddir
cd ~
for file in $files; do
if [ -h ".$file" ]; then
echo "~/.$file is already symlink to `readlink -f .$file`"
else
if [ -e ".$file" ]; then
echo "Moving ~/.$file to $olddir for backup"
mv ~/.$file $olddir
fi
echo "Creating symlink to $dir/$file in ~"
ln -s $dir/$file ~/.$file
fi
done
for file in $configs; do
if [ -h ".config/$file" ]; then
echo "~/.config/$file is already symlink to `readlink -f .config/$file`"
else
if [ -e ".config/$file" ]; then
echo "Moving ~/.config/$file to $olddir for backup"
mv ~/.$file $olddir
fi
echo "Creating symlink to $dir/$file in ~/.config"
ln -s $dir/$file ~/.config/$file
fi
done