-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·27 lines (25 loc) · 929 Bytes
/
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
dotfiles=(.bashrc .vimrc)
autogen_begin="# AUTOGEN: begin (dotfiles/setup.sh)"
autogen_end="# AUTOGEN: end"
for dotfile in ${dotfiles[@]}; do
if ! [ -f $dotfile ]; then # if dotfile does not exist
echo "creating new dotfile: $dotfile"
add_dotfile=true
else # if dotfile exists
if [ $(grep -xc "$autogen_begin" $dotfile) -eq 0 ]; then # if autogen not present
echo "adding to existing dotfile: $dotfile"
echo "" >> $dotfile
add_dotfile=true
else # if autogen already present
echo "dotfile already set up: $dotfile"
add_dotfile=false
fi
fi
if [ "$add_dotfile" == true ]; then
echo $autogen_begin >> $dotfile
echo "if [ -f dotfiles/$dotfile ]; then" >> $dotfile
echo " source dotfiles/$dotfile" >> $dotfile
echo "fi" >> $dotfile
echo $autogen_end >> $dotfile
fi
done