-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsetup.sh
executable file
·244 lines (223 loc) · 6.48 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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/bash
#
# This file was written by Robert Quattlebaum <[email protected]>.
#
# This work is provided as-is. Unless otherwise provided in writing,
# Robert Quattlebaum makes no representations or warranties of any
# kind concerning this work, express, implied, statutory or otherwise,
# including without limitation warranties of title, merchantability,
# fitness for a particular purpose, non infringement, or the absence
# of latent or other defects, accuracy, or the present or absence of
# errors, whether or not discoverable, all to the greatest extent
# permissible under applicable law.
#
# To the extent possible under law, Robert Quattlebaum has waived all
# copyright and related or neighboring rights to this work. This work
# is published from the United States.
#
# I, Robert Quattlebaum, dedicate any and all copyright interest in
# this work to the public domain. I make this dedication for the
# benefit of the public at large and to the detriment of my heirs and
# successors. I intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to
# this code under copyright law. In jurisdictions where this is not
# possible, I hereby release this code under the Creative Commons
# Zero (CC0) license.
#
# * <http://creativecommons.org/publicdomain/zero/1.0/>
#
HOMEDIR=~
SHATDIR="$HOMEDIR/.shattings"
die () {
echo $*
exit 1
}
# set -x
echo 'This script will either create or update the following files:'
echo ''
echo ' ~/.bashrc'
echo ' ~/.zshrc'
echo ' ~/.vimrc'
echo ' ~/.kermrc'
echo ' ~/.screenrc'
echo ' ~/.tmux.conf'
echo ' ~/.inputrc'
echo ' ~/.profile'
echo ' ~/.profile_comp'
echo ' ~/.Xdefaults'
echo ' ~/.gnupg/gpg.conf'
echo ''
echo 'If the file already exists, it will be non-destructively'
echo 'modified by appending commented-out commands. In this case'
echo 'you will need to edit the respective file manually to'
echo 'enable shattings.'
echo ''
read -p 'Press any key to continue setup or CTRL-C to abort.'
sleep 1
if [ -e "$HOMEDIR/.bashrc" ]
then
if grep -q "$SHATDIR/bash/bashrc" $HOMEDIR/.bashrc
then echo $HOMEDIR/.bashrc is already good to go.
else
{
echo '# Uncomment to enable shattings'
echo '# '"[ -d \"$SHATDIR\" ] && . \"$SHATDIR/bash/bashrc\""
} >> "${HOMEDIR}/.bashrc"
echo Added stub to existing $HOMEDIR/.bashrc, make sure you edit it
fi
else
{
echo "[ -d \"$SHATDIR\" ] && . \"$SHATDIR/bash/bashrc\""
} >> "${HOMEDIR}/.bashrc"
echo Created $HOMEDIR/.bashrc
fi
if [ -e "$HOMEDIR/.zshrc" ]
then
if grep -q "profile_comp" $HOMEDIR/.zshrc
then echo $HOMEDIR/.zshrc is already good to go.
else
{
echo "[ -f ~/.profile_comp ] && source ~/.profile_comp"
} >> "${HOMEDIR}/.zshrc"
echo Updated $HOMEDIR/.zshrc
fi
else
{
echo "[ -f ~/.profile_comp ] && source ~/.profile_comp"
} >> "${HOMEDIR}/.zshrc"
echo Created $HOMEDIR/.zshrc
fi
if [ -e "$HOMEDIR/.profile_comp" ]
then
echo Skipping $HOMEDIR/.profile_comp
else
echo Updating $HOMEDIR/.profile_comp
$SHATDIR/bin/refresh-shell-profile > $HOMEDIR/.profile_comp
fi
if [ -e "$HOMEDIR/.profile" ]
then
if grep -q ". ~/.bashrc" $HOMEDIR/.profile
then echo $HOMEDIR/.profile is already good to go.
else
{
echo '# Uncomment to enable shattings'
echo '# '". ~/.bashrc"
} >> "${HOMEDIR}/.profile"
echo Added stub to existing $HOMEDIR/.profile, make sure you edit it
fi
else
{
echo ". ~/.bashrc"
} >> "${HOMEDIR}/.profile"
echo Created $HOMEDIR/.profile
fi
if [ -e "${HOMEDIR}/.vimrc" ]
then
if grep -q "$SHATDIR/vim/vimrc" $HOMEDIR/.vimrc
then echo $HOMEDIR/.vimrc is already good to go.
else
{
echo '" Uncomment to enable shattings'
echo '" '"source $SHATDIR/vim/vimrc"
} >> "${HOMEDIR}/.vimrc"
echo Added stub to existing $HOMEDIR/.vimrc, make sure you edit it
fi
else
{
echo "source $SHATDIR/vim/vimrc"
} >> "${HOMEDIR}/.vimrc"
echo Created $HOMEDIR/.vimrc
fi
if [ -d "${HOMEDIR}/.vim" ]
then
echo "$HOMEDIR/.vim" already exists, skipping...
else
ln -s "${SHATDIR}/vim" "${HOMEDIR}/.vim"
echo Linked $HOMEDIR/.vim
fi
if [ -e "${HOMEDIR}/.gnupg/gpg.conf" ]
then
echo "$HOMEDIR/.gnupg/gpg.conf" already exists, skipping...
else
ln -s "${SHATDIR}/etc/gpg.conf" "${HOMEDIR}/.gnupg/gpg.conf"
echo Linked $HOMEDIR/.gnupg/gpg.conf
fi
if [ -e "${HOMEDIR}/.screenrc" ]
then
if grep -q "$SHATDIR/screen/screenrc" $HOMEDIR/.screenrc
then echo $HOMEDIR/.screenrc is already good to go.
else
{
echo '# Uncomment to enable shattings'
echo '# '"source \"$SHATDIR/screen/screenrc\""
} >> "${HOMEDIR}"/.screenrc
echo Added stub to existing $HOMEDIR/.screenrc, make sure you edit it
fi
else
{
echo "source \"$SHATDIR/screen/screenrc\""
} >> "${HOMEDIR}"/.screenrc
echo Created $HOMEDIR/.screenrc
fi
if [ -e "${HOMEDIR}/.inputrc" ]
then
if grep -q "$SHATDIR/etc/inputrc" $HOMEDIR/.inputrc
then echo $HOMEDIR/.inputrc is already good to go.
else
{
echo '# Uncomment to enable shattings'
echo '# '"\$include $SHATDIR/etc/inputrc\""
} >> "${HOMEDIR}"/.inputrc
echo Added stub to existing $HOMEDIR/.inputrc, make sure you edit it
fi
else
{
echo "\$include $SHATDIR/etc/inputrc"
} >> "${HOMEDIR}"/.inputrc
echo Created $HOMEDIR/.inputrc
fi
if [ -e "${HOMEDIR}/.tmux.conf" ]
then
if grep -q "$SHATDIR/etc/tmux.conf" $HOMEDIR/.tmux.conf
then echo $HOMEDIR/.tmux.conf is already good to go.
else
{
echo '# Uncomment to enable shattings'
echo '# '"source \"$SHATDIR/etc/tmux.conf\""
} >> "${HOMEDIR}"/.tmux.conf
echo Added stub to existing $HOMEDIR/.tmux.conf, make sure you edit it
fi
else
{
echo "source \"$SHATDIR/etc/tmux.conf\""
} >> "${HOMEDIR}"/.tmux.conf
echo Created $HOMEDIR/.tmux.conf
fi
if [ -e "${HOMEDIR}/.Xdefaults" ]
then
echo "${HOMEDIR}/.Xdefaults already exists. Skipping..."
else
ln -s "${SHATDIR}/etc/Xdefaults" "${HOMEDIR}/.Xdefaults"
echo Linked "$HOMEDIR/.Xdefaults" to "${SHATDIR}/etc/Xdefaults".
fi
if [ -e "${HOMEDIR}/.kermrc" ]
then
if grep -q "$SHATDIR/etc/kermrc" $HOMEDIR/.kermrc
then echo $HOMEDIR/.kermrc is already good to go.
else
{
echo '# Uncomment to enable shattings'
echo '# '"take $SHATDIR/etc/kermrc"
} >> "${HOMEDIR}/.kermrc"
echo Added stub to existing $HOMEDIR/.kermrc, make sure you edit it
fi
else
{
echo "take $SHATDIR/etc/kermrc"
} >> "${HOMEDIR}/.kermrc"
echo Created $HOMEDIR/.kermrc
fi
echo 'Done! Shattings is now set up.'
echo 'Remember to edit the files mentioned above, if any.'
echo ''
echo 'Consider installing ohmyzsh: sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"'