-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
58 lines (46 loc) · 1.15 KB
/
setup.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
#!/bin/sh
#
# Creates local links for .dot files into ~/
#
# because ubuntu uses ~/.profile, not .bash_profile
if [ "$1" == "" ];then
profileFileName=.bash_profile
else
profileFileName=$1
fi
cd `dirname $0`
mydir=$PWD
# linkfile ~/.filename
function linkfile
{
[ "$1" == "" ] && exit
file=$1
dir=`dirname $file`
fname=`basename $file`
now=`date +%s`
[ -h $file ] && echo "ALREADY A SYMLINK: $file" && return
[ ! -f $mydir/$fname ] && echo "Missing file: $mydir/$fname" && return 255
[ -f $file ] && cp $file /tmp/$fname.$file.$now
[ -f $file ] && mv $file $file.bak
cd $dir
ln -sv $mydir/$fname
}
linkfile ~/.gitconfig
linkfile ~/.vimrc
linkfile ~/.screenrc
## setup .bash_profile
if [ -e ~/$profileFileName ];then
## Check if line exists
tmp=`cat ~/$profileFileName | grep "\-f.$mydir"`
if [ $? != 0 ];then
echo "[ -f $mydir/$profileFileName ] && . $mydir/$profileFileName" >> ~/$profileFileName
fi
else
echo "[ -f $mydir/$profileFileName ] && . $mydir/$profileFileName" >> ~/$profileFileName
fi
cd ~/
[ ! -e $mydir ] && ln -s $mydir
echo "PATH=$PATH:$mydir/bin" > /tmp/timpath
echo "export PATH" >> /tmp/timpath
source /tmp/timpath
exit 0