forked from jimlawton/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_setupdotfiles.sh
executable file
·61 lines (51 loc) · 1.46 KB
/
_setupdotfiles.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
SHELLSCONFIGDIR=~/dotfiles
DOTFILESDIR=~/dotfiles
DOTFILES=".autoenv .bash_logout .bash_profile .bashrc .colordiffrc .colorgccrc .git_identities .gitconfig .gitignore .inputrc .profile .pythonrc .tmux .tmux.conf .vimrc .vim .xxdiffrc"
MOVE=true
SAVEDIR=~/.old
function symlinkifne {
target=~/$1
echo "Working on: $target"
export dotless=`echo $1 | sed s/^\.//`
if [ -e $target ]; then
echo " WARNING: $target already exists!"
if [ "$MOVE" = "true" ]; then
echo " Moving $target to ~/.old/"
mv $target ~/.old/
dotless=$(echo $1 | sed s/.//)
echo " Symlinking $DOTFILESDIR/$dotless to $1"
ln -s $DOTFILESDIR/$dotless $target
else
echo " Skipping $1."
fi
else
echo " Symlinking $DOTFILESDIR/$dotless to $1"
ln -s $DOTFILESDIR/$dotless $1
fi
}
echo "This script must be run from the dotfiles directory"
echo "Setting up..."
pushd ~
if [ -d $SAVEDIR ]; then
echo "$SAVEDIR already exists! Please clean up and try again."
echo "This is usesd to save old versions of your configuration files."
exit 1
fi
mkdir $SAVEDIR
if [ ! -d dotfiles ]; then
echo "The dotfiles dir does not exist in your home directory!"
echo "You need to do:"
echo "# cd ~"
echo "# git clone --recurse-submodules https://github.com/matthewmccullough/dotfiles"
echo "# cd dotfile"
echo "# ./_setupdotfiles.sh"
exit 1
fi
for dotfile in $DOTFILES; do
symlinkifne $dotfile
done
if [ ! -e ~/bin ]; then
ln -s ~/Dropbox/unixhome/bin ~
fi
popd
echo "Done!"