-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall
executable file
·198 lines (173 loc) · 5.98 KB
/
install
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
#!/usr/bin/env sh
####
#### Sanity checks.
####
# Check for supported OSes
os="$(uname)"
free_oses='FreeBSD Linux'
mac_os='Darwin'
all_oses="${free_oses} ${mac_os}"
support='false'
for item in ${all_oses}; do
if echo "${item}" | grep -wq "${os}"; then
support='true'
fi
done
if [ "${support}" = 'false' ]; then
printf 'OS: '\''%s'\'' is not supported.\n' "${os}"
printf 'Supported OS are: '\''%s'\''.\n' "${all_oses}"
exit 1
fi
# Set os family
os_family='free'
if [ "${os}" = 'Darwin' ]; then
os_family="${os}"
fi
# Check for minimum needed software.
dependencies='stow git wget'
for dep in ${dependencies}; do
if ! [ "$(command -v "${dep}")" ]; then
printf '\033[31minstall.sh has following dependencies '\''%s'\''\n' \
"${dependencies}"
printf 'Exiting...\n\033[0m'
exit 1
fi
done
# Parse environment variables for repo branch to use.
if [ -z "${GIT_BRANCH}" ]; then
GIT_BRANCH='prod'
fi
####
#### Function definitions.
####
_clone_dotfiles() {
dotfiles_target="$HOME/.dotfiles"
printf '\033[32mCloning repo into: \033[34m"%s"\n\033[0m' \
"${dotfiles_target}"
git clone --recursive https://github.com/oliverwiegers/dotfiles \
"${dotfiles_target}" || exit 1
cd "${dotfiles_target}" || exit 1
git checkout "${GIT_BRANCH}"
git pull origin "${GIT_BRANCH}"
cd "$HOME" || exit 1
printf '\033[32mDone cloning dotfiles.\n\n\033[0m'
}
_clone_omz() {
omz_target="$HOME/.oh-my-zsh"
printf '\033[32mCloning oh-my-zsh into: \033[34m%s\n\033[0m' "${omz_target}"
git clone https://github.com/robbyrussell/oh-my-zsh.git "${omz_target}" \
|| exit 1
cd "$HOME" || exit 1
printf '\033[32mDone cloning oh-my-zsh.\n\n\033[0m'
}
_create_symlinks() {
printf '\033[32mCreating symlinks.\n\033[0m'
cd "$HOME/.dotfiles" || exit 1
if [ "${os_family}" = 'free' ]; then
stow homedir
stow config
mkdir "$HOME/.themes"
ln -s "$HOME/.dotfiles/extra/gruvbox-gtk" "$HOME/.themes/"
elif [ "${os_family}" = 'Darwin' ]; then
if [ ! -d "$HOME/.config" ]; then
mkdir -p "$HOME/.config/"
fi
ln -s "$HOME/.dotfiles/config/.config/zsh/" "$HOME/.config/zsh"
ln -s "$HOME/.dotfiles/homedir/.zshrc" "$HOME/.zshrc"
ln -s "$HOME/.dotfiles/homedir/.p10k.zsh" "$HOME/.p10k.zsH"
ln -s "$HOME/.dotfiles/homedir/.taskrc" "$HOME/.taskrc"
ln -s "$HOME/.dotfiles/config/.config/neofetch/" \
"$HOME/.config/neofetch"
ln -s "$HOME/.dotfiles/config/.config/ranger/" \
"$HOME/.config/ranger"
fi
printf '\033[32mDone creating symlinks.\n\n\033[0m'
}
_install_fonts() {
printf '\033[32mInstalling fonts.\n\033[0m'
if [ "${os_family}" = 'free' ]; then
if [ ! -d "${HOME}/.local/share/fonts/" ]; then
mkdir -p "${HOME}/.local/share/fonts/"
fi
wget -O "${HOME}/.local/share/fonts/source_code_pro_bold.ttf" \
https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/SourceCodePro/Bold/complete/Sauce%20Code%20Pro%20Bold%20Nerd%20Font%20Complete%20Mono.ttf
wget -O "${HOME}/.local/share/fonts/source_code_pro_regular.ttf" \
https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/SourceCodePro/Regular/complete/Sauce%20Code%20Pro%20Nerd%20Font%20Complete%20Mono.ttf
fc-cache -r
fi
printf '\033[32mDone installing fonts.\n\n\033[0m'
}
_install_vim_config() {
vim_target="$HOME/.vim"
printf '\033[32mCloning vim config into: \033[34m%s\n\033[0m' \
"${vim_target}"
if [ -d "${vim_target}" ]; then
rm -r "${vim_target}"
fi
git clone --recursive https://github.com/oliverwiegers/vim_config \
"${vim_target}" || exit 1
cd "$HOME/.vim" || exit 1
stow vimrc
./helper-scripts/manage-coc.sh -i
cd "$HOME" || exit 1
printf '\033[32mDone installing Vim config.\n\n\033[0m'
}
_install_tmux_config() {
tmux_target="$HOME/.tmuxist"
printf '\033[32mCloning tmux config into: \033[34m%s\n\033[0m' \
"${tmux_target}"
git clone --recursive https://github.com/chrootzius/tmuxist \
"${tmux_target}" || exit 1
cd "$HOME/.tmuxist" || exit 1
stow tmux
cd "$HOME" || exit 1
printf '\033[32mDone installing Tmux config.\n\n\033[0m'
}
_install_scripts() {
printf '\033[32mInstalling scripts.\n\033[0m'
cd "$HOME" || exit 1
if [ ! -d "$HOME/.local/bin/" ]; then
mkdir -p "$HOME/.local/bin/"
fi
ln -s "$HOME/.dotfiles/extra/bin/scripts" "$HOME/.local/bin/"
cd "$HOME" || exit 1
printf '\033[32mDone installing scripts.\n\n\033[0m'
}
_output_header() {
printf '%b' '\033[34m'
echo '.___ __ .__ .__ .__'
echo '| | ____ _______/ |_ _____ | | | | |__| ____ ____'
# shellcheck disable=SC2028
echo '| | / \ / ___/\ __\\\__ \ | | | | | | / \ / ___\ '
echo '| || | \ \___ \ | | / __ \_| |__| |__| || | \ / /_/ >'
echo '|___||___| //____ > |__| (____ /|____/|____/|__||___| / \___ /'
echo ' \/ \/ \/ \/ /_____/'
echo '________ __ _____ .__ .__'
echo '\______ \ ____ _/ |_ _/ ____\|__|| | ____ ______'
# shellcheck disable=SC2028
echo ' | | \ / _ \ \ __\\\ __\ | || | _/ __ \ / ___/'
echo ' | ` \( <_> ) | | | | | || |__\ ___/ \___ \ '
echo '/_______ / \____/ |__| |__| |__||____/ \___ >/____ >'
echo ' \/ \/ \/'
echo ' '
echo ' /\ /\ /\ '
echo ' \/ \/ \/ '
printf '%b' '\033[0m'
}
_main() {
# Print header.
_output_header
# Install configuration
_clone_dotfiles
_clone_omz
_create_symlinks
_install_fonts
_install_vim_config
_install_tmux_config
_install_scripts
printf '\033[32mFinally done.\033[0m\n'
}
####
#### Actually run all the stuff.
####
_main "$@"