-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_links
executable file
·45 lines (37 loc) · 1 KB
/
setup_links
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
#!/bin/bash
# Setup dotfile links from etc to HOME dir
# cd to etc dir and run script
function relative () {
perl -e 'use File::Spec; print File::Spec->abs2rel(@ARGV) . "\n"' $1 $2
}
function safe_link () {
src="$PWD/$1"
dst="$HOME/$2"
if [ -e $dst ]; then
echo dst file already exists: $dst
return
fi
if [ -e $src ]; then
s=$(relative $src $HOME)
echo Linking $s to $dst
ln -s $s $dst
else
echo src file does not exist: $src
fi
}
perl -v > /dev/null || { echo "Perl is not installed"; exit 1; }
# Shell
safe_link bash_profile .bash_profile
safe_link bashrc .bashrc
safe_link git-prompt-colors.sh .git-prompt-colors.sh
# Editor
safe_link emacs.d .emacs.d
safe_link emacs.d/dotemacs.el .emacs
safe_link vimrc .vimrc
# Git
safe_link gitconfig .gitconfig
safe_link gitignore .gitignore
# Ruby
safe_link irbrc .irbrc
safe_link rvmrc .rvmrc
safe_link gemrc .gemrc