-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_homedir
executable file
·65 lines (53 loc) · 1.63 KB
/
setup_homedir
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
#!/bin/bash
Help="Usage: `basename $0` file [file ...]
Options:
--help print this message
--all link all files in ./dotfiles
Creates hidden symbolic links for each file in the argument list to ~ (\$HOME)
(i.e., prefaces each name with a '~/.'), saving any existing dotfiles in
./dot_backup. Subsequent edits can be on eitehr version of the file, but
remember to commit and push your changes periodically.
This was written to be part of the setup when installing the
http://github.com/gltarsa/homedir repo.
"
case $1 in
""|--help|-h*|--h*) echo 2>&1 "? $Help"
exit
;;
--all|-a*|--a*)
set ./dotfiles/*
;;
esac
test -d $1 && {
echo 2>&1 "?$1 is a directory. Did you mean $1/*?"
exit
}
dest_dir=~
backup_dir=~/.dot_backup
for i in $@
do
src_name=`pwd`/$i # force filenames to be fully qualified so ln -s works
bare_name=`basename $i`
dest_name=~/.$bare_name
# destination exists? save it to the backup dir unless already there
# if already there, assume we are re-running this script and do not
# want to overwrite the backups
test -e $dest_name && test ! -e $backup_dir/.$bare_name &&
{
mkdir -p $backup_dir
echo "$dest_name already exists, moving to $backup_dir"
mv $dest_name $backup_dir
}
echo "Linking $src_name ---> $dest_name"
test -e $dest_name && rm -r $dest_name
ln -s $src_name $dest_name
done
# install vundle, if necessary
vundle_dest=~/bin/dotfiles/vim/bundle/Vundle.vim
set $vundle_dest/*
case `ls -1 $vundle_dest 2> /dev/null | wc -l | sed 's/ //g'` in
0)
echo "Installing Vundle"
git clone https://github.com/VundleVim/Vundle.vim.git $vundle_dest
;;
esac