-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetuplinks.sh
More file actions
executable file
·166 lines (151 loc) · 3.08 KB
/
setuplinks.sh
File metadata and controls
executable file
·166 lines (151 loc) · 3.08 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/zsh
# Resolve symlinks
if [[ ( "$1" == "") ]]
then
configname=$(hostname -s)
else
configname=$1
fi
cd ${0:h}
configdir=`pwd`
configdir=${configdir#~/}
# CreateLink (from to)
# Creates a link from $from to $to,
# removing the old link, or moving the old
# file to $from.old
function CreateLink ()
{
from=~/$1
from_pretty=\~/$1
if [[ ( "$2" == "" ) ]]
then
arg2=$1
else
arg2=$2
fi
to=~/$configdir/$1
to_pretty=\~/$configdir/$arg2
if [[ -a $to.$configname ]]
then
to=$to.$configname
to_pretty=$to_pretty.$configname
fi
echo
echo Creating a link from $from_pretty to $to_pretty
if [[ $to == $(readlink $from) ]]
then
echo "Link already exists and is correct."
return
fi
if [[ -h $from ]]
then
echo -n $from_pretty exists as a link to $(readlink $from), remove it'? [Y/n]'
read -n 1 answer
if [[ ! $answer == '
' ]]
then
echo
fi
if [[ $answer == n || $answer == N ]]
then
return
fi
echo Ok, removing...
rm $from
fi
if [[ ( -f $from ) && ! ( -h $from ) ]]
then
echo -n $from_pretty exists as a file, rename to $from_pretty.old'? [Y/n]'
read -n 1 answer
if [[ ! $answer == '
' ]]
then
echo
fi
if [[ $answer == n || $answer == N ]]
then
return
fi
echo Ok, renaming...
mv $from $from.old
fi
if [[ ( -d $from ) && ! ( -h $from ) ]]
then
echo -n $from_pretty exists as a directory, rename to $from_pretty.old'? [Y/n]'
read -n 1 answer
if [[ ! $answer == '
' ]]
then
echo
fi
if [[ $answer == n || $answer == N ]]
then
return
fi
echo Ok, renaming...
mv $from $from.old
fi
echo Creating the link...
ln -s $to $from
}
function CreateDir ()
{
dir=~/$1
dir_pretty=\~/$1
echo
echo Creating directory $dir_pretty
if [[ ( -d $dir ) ]]
then
echo -n "Directory already exists."
return
fi
if [[ ( -f $dir ) && ! ( -d $dir ) ]]
then
echo -n $dir_pretty exists as a file, rename to $dir_pretty.old'? [Y/n]'
read -n 1 answer
if [[ ! $answer == '
' ]]
then
echo
fi
if [[ $answer == n || $answer == N ]]
then
return
fi
echo Ok, renaming...
mv $dir $dir.old
fi
echo Creating the directory...
mkdir $dir
}
echo CONFIGNAME=$configname
CreateLink .environment
CreateLink .setenv
CreateLink .alias
CreateLink .zshrc
CreateLink .zprofile
CreateLink .zlogin
CreateDir .zsh
CreateLink .zsh/prompt.sh
CreateLink .zsh/zsh-git-prompt
CreateLink .cvsrc
CreateLink .gitconfig
CreateLink .inetrc
CreateLink .emacs
CreateDir .emacs.d
CreateLink .emacs.d/environment.el
CreateLink .emacs.d/abbrev.el
CreateLink .emacs.d/blinkprotocol
CreateLink .emacs.d/gecko-mode
CreateLink .emacs.d/markdown
CreateLink .emacs.d/groovy-emacs-modes
CreateLink .emacs.d/yaml-mode
CreateLink .emacs.d/protobuf-mode
CreateDir bin
CreateLink bin/date2stamp
CreateLink bin/stamp2date
CreateLink bin/expand_inplace
CreateLink bin/gw
if [[ "$configname" == "macos" ]]; then
CreateLink bin/emacs
fi