-
Notifications
You must be signed in to change notification settings - Fork 2
/
mklinks.sh
executable file
·79 lines (64 loc) · 1.45 KB
/
mklinks.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
72
73
74
75
76
77
78
79
#!/bin/sh
mydir=$(dirname "$(readlink -f "$0")")
set -e
link()
{
target="$mydir/$1"
link=$2
mkdir -vp "$(dirname "$link")"
if [ ! -e "$link" ]; then
ln -vs "$target" "$link"
return
fi
currenttarget=`readlink -f "$link"`
if [ "$currenttarget" = "$target" ]; then
echo "$link -> $target already in place"
return
fi
echo "$link exists and is not a link to $target" >&2
exit 1
}
inodeno()
{
ls -i "$1" | awk '{ print $1 }'
}
hardlink()
{
target="$mydir/$1"
link=$2
if [ ! -e "$link" ]; then
ln "$target" "$link"
return
fi
if [ `inodeno $link` -eq `inodeno $link` ]; then
echo "$link => $target already in place"
return
fi
echo "$link exists and is not a hardlink of $target" >&2
exit 1
}
link "emacs" ~/.emacs
link "bash_aliases" ~/.bash_aliases
link "bashrc" ~/.bashrc
link "profile" ~/.profile
case `uname -o` in
Cygwin)
# can't use a symlink here
hardlink "gitconfig.cygwin" ~/.gitconfig
;;
*)
link "gitconfig" ~/.gitconfig
;;
esac
link "inputrc" ~/.inputrc
link "lynxrc" ~/.lynxrc
link "ssh_config" ~/.ssh/config
link "svn_config" ~/.subversion/config
link "hgrc/hgrc" ~/.hgrc
link "bcrc" ~/.bcrc
link "gdbinit" ~/.gdbinit
link "upstart" ~/.config/upstart
link "devscripts" ~/.devscripts
link "dput.cf" ~/.dput.cf
link "xsessionrc" ~/.xsessionrc
link "direnvrc" ~/.direnvrc