-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·171 lines (161 loc) · 4.12 KB
/
setup.sh
File metadata and controls
executable file
·171 lines (161 loc) · 4.12 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
166
167
168
169
170
171
#!/usr/bin/env bash
#===============================================================================
# FILE: setup.sh
# USAGE: ./setup.sh
#
# DESCRIPTION: Setup dotfiles
#
# OPTIONS: -h usage
# REQUIREMENTS: bash, vim 7+, nvim 0.1+
# BUGS:
# NOTES:
# AUTHOR: Alberto Sadde
# CREATED: 03/15/2014 20:35
# VERSION: 0.2
#===============================================================================
#Variables: {{{1
DOTFILES_ROOT=$PWD
#}}}
#Functions: All functions are declared here {{{1
#Function: usage() prints the usage instructions {{{2
function usage() {
echo -e "Need to select at least one option\n"
echo -e "-h for help\n-all for all dotfiles\n-vim just for vim dotfiles\n-bash
just for bash dotfiles\n-git for git dotfiles\n-clean to remove old dotfiles"
exit 1
}
#2}}}
#Function: parseOptions() parses the options selected by user {{{2
function parseOptions() {
case "$1" in
-h)
usage
;;
-all)
all
;;
-vim)
vimFiles
;;
-nvim)
nvimFiles
;;
-vimperator)
vimperator
;;
-shell)
shellFiles
;;
-git)
gitFiles
;;
-jobs)
installJobs
;;
-clean)
removeOldDotFiles
;;
-osx)
.$DOTFILES_ROOT/osx
esac
}
#2}}}
#Function: removeOldDotFiles() cleans up home directory from old dotfiles if they exist {{{2
function removeOldDotFiles() {
for file in $HOME/.{config/nvim,vimperator,vimperatorrc,zshrc,ghci.conf,scripts,tmux.conf,gitignore,gitconfig,gitattributes,bash_profile,aliases,bashrc,exports,config/init.vim,customFunctions}; do
if [ -e $file ]; then
rm -rf $file
fi
done
unset file
if [ -d $HOME/.config ]; then
rm -rf $HOME/.config
fi
}
#2}}}
#Function: shellFiles() sets the shell dotfiles {{{2
function shellFiles() {
echo -e "Changing to zsh - Be ready to sudo"
/usr/bin/sudo apt-get install zsh
chsh
ln -s $DOTFILES_ROOT/aesadde.zsh-theme $HOME/.oh-my-zsh/themes/aesadde.zsh-theme
echo -e "Install oh-my-zsh"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
rm $HOME/.zshrc*
for file in {ghci.conf,zshrc,bash_profile,bashrc,tmux.conf}; do
if [ -f $HOME/.$file ]; then
rm $HOME/.$file
fi
ln -s $DOTFILES_ROOT/$file $HOME/.$file
done
unset file
if [ ! -e $HOME/.scripts ]; then
ln -s $DOTFILES_ROOT/scripts $HOME/.scripts
fi
echo -e "All shell dotfiles up and running!\n"
}
#2}}}
#Function: vimFiles() sets .vimrc and .vim {{{2
function vimFiles() {
git submodule init; git submodule update
ln -s $DOTFILES_ROOT/vim $HOME/.vim
ln -s $DOTFILES_ROOT/vim/vimrc $HOME/.vimrc
echo -e "Vim files and plugins up and running!\n"
cd $DOTFILES_ROOT
}
#2}}}
#Function: nvimFiles() sets .nvimrc and .nvim {{{2
function nvimFiles() {
if [ ! -d $HOME/.config ]; then
mkdir -p $HOME/.config
fi
ln -s $DOTFILES_ROOT/nvim $HOME/.config/nvim
ln -s $DOTFILES_ROOT/nvim/init.vim $HOME/.config/init.vim
cd $DOTFILES_ROOT
}
#2}}}
#Function: vimperator() sets vimperator options {{{2
function vimperator() {
# if [ -d /Applications/Firefox.app ]; then
ln -s "$DOTFILES_ROOT/vimperator" "$HOME/.vimperator"
ln -s "$DOTFILES_ROOT/vimperator/vimperatorrc" "$HOME/.vimperatorrc"
# fi
}
#Function: gitFiles() sets global git config dotfiles {{{2
function gitFiles() {
for file in {gitignore,gitconfig}; do
if [ -f $HOME/.$file ]; then
rm $HOME/.$file
fi
ln -s $DOTFILES_ROOT/$file $HOME/.$file
done
unset file
echo -e "All git config files up and running!\n"
}
#2}}}
#Function: installJobs() installs all jobs in jobs dir {{{2
function installJobs() {
LAUNCH=/Library/LaunchAgents
cd $DOTFILES_ROOT/jobs
for file in *; do
/usr/bin/sudo cp $file $LAUNCH/.
/usr/bin/sudo chown root:wheel $LAUNCH/$file
sudo launchctl load $LAUNCH/$file
done
cd $DOTFILES_ROOT
}
#2}}}
#Function: all() sets all dotfiles {{{2
function all() {
shellFiles
vimperator
nvimFiles
nvimFiles
gitFiles
}
#2}}}
#Main: {{{
# check we are given at least one parameter
[[ $# -ne 1 ]] && usage
parseOptions $1
#}}}