blob: b791a4fc15b6403bf6dbf71cbdcefb503aa1490e (
plain)
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
|
#!/bin/bash
set -e
cd "`dirname $0`"
date="`date +'%Y%m%d'`"
dir="`pwd`"
if [ "$dir" = "$HOME" ]; then
relpath=""
else
relpath="${dir##$HOME/}/"
fi
for file in bash_profile bashrc gitconfig gitignore screenrc vimrc zshrc zshfunc terminfo tmux.conf; do
if [ -L "$HOME/.$file" ]; then
if [ "$(readlink "$HOME/.$file")" != "$dir/$file" ]; then # old style symlink, remove
rm -v -f "$HOME/.$file"
fi
fi
if ! [ -L "$HOME/.$file" ]; then
if [ -e "$HOME/.$file" ]; then
if [ "$file" = "bashrc" ] &&
md5sum $HOME/.$file | grep -q eed8ae914410b3f768d345824117fd0b ; then # default lenny
rm -v -f "$HOME/.$file"
else
mv "$HOME/.$file" "$HOME/.$file-$date"
fi
elif [ -L "$HOME/.$file" ]; then # dangling symlink
rm -f "$HOME/.$file"
fi
ln -v -s "$relpath$file" "$HOME/.$file"
fi
done
|