-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathInstall
executable file
·279 lines (211 loc) · 8.09 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
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/bin/bash
set -e
# Flag to only install dotfiles and not packages
flag="${1}"
# This gets the OS of current machine.
MY_OS="$(uname -s)"
MY_DISTRO="none"
MY_ARCHITECTURE="none"
# Current working directory. We'll need to come back to this later
INITIAL_WORKING_DIRECTORY=$(pwd)
# Directory of install script
SCRIPT_DIRECTORY=$(dirname "$0")
SKIP=false
###############################################################################
# Find OS and Distro Name
###############################################################################
function no_packages() {
cat << EOF
Can't install packages on this device. Package installation is not supported on you OS or Distro
Please install any packages on your own. The list of of packages are located at:
/~https://github.com/abasnfarah/dotfiles/blob/main/install
To get a list of packages to stdout run 'install' with the -l flag
To install without packages, re-run the script with the following flag
bash <(/~https://github.com/abasnfarah/dotfiles/blob/main)> --skip-packages
EOF
}
case $MY_OS in
Darwin*)
MY_OS="macOS" && MY_DISTRO="macOS"
if [ -d "/opt" ]; then
MY_ARCHITECTURE="ARM"
else
MY_ARCHITECTURE="x86_64"
fi
;;
Linux*)
MY_OS="Linux"
if [ -f "/etc/arch-release" ]; then
MY_DISTRO="Arch"
else
if [ -f "/etc/debian_version" ]; then
MY_DISTRO="Ubuntu"
else
[ -z "${skip_packages}" ] && no_packages
fi
fi
;;
*)
MY_OS="Other"
[ -z "${skip_packages}" ] && no_packages
;;
esac
###############################################################################
# Handle flags
###############################################################################
function list_packages {
if [ $MY_OS = "macOS" ]; then
source ./brew.sh
elif [ $MY_OS = "Linux" ] && [ $MY_DISTRO = "Arch" ]; then
echo "$(curl -fsSL https://raw.githubusercontent.com/abasnfarah/dotfiles/archbox/utils/arch/framework.sh)" > ./framework.sh
source ./framework.sh
rm -rf ./framework.sh
#source ./utils/arch/framework.sh
elif [ $MY_OS = "Linux" ] && [ $MY_DISTRO = "Ubuntu" ]; then
source ./ubuntu.sh
fi
display_packages
exit 0
}
while test $# -gt 0; do
case "$1" in
-h|--help)
echo ""
echo "Install tool for Neovim, tmux, and various packages for a fresh setup."
echo ""
echo "install [options]"
echo ""
echo "options:"
echo "-h, --help show brief help"
echo "-s, --skip_packages skips package install"
echo "-l, --list_packages lists packages to install per OS"
exit 0
;;
-l)
shift
list_packages
shift
;;
--list_packages)
list_packages
shift
;;
-s)
shift
echo "Skipping package install"
echo ""
echo "To get a list of packages run 'install -l'"
shift
;;
--skip_packages)
echo "Skipping package install"
echo ""
echo "To get a list of packages run 'install -l'"
shift
;;
*)
break
;;
esac
done
###############################################################################
# Install packages using OS or distro package manager
###############################################################################
echo "Starting bootstrapping.."
echo "..."
sleep .10
function install_macos {
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/abasnfarah/dotfiles/HEAD/utils/macOS/brew.sh)"
}
function install_arch {
#/bin/bash -c "$(curl -fLo https://raw.githubusercontent.com/abasnfarah/dotfiles/main/utils/arch/arch.sh)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/abasnfarah/dotfiles/archbox/utils/arch/arch.sh)"
}
function install_ubuntu {
#/bin/bash -c "$(curl -fLo https://raw.githubusercontent.com/abasnfarah/dotfiles/main/utils/ubuntu/ubuntu.sh)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/abasnfarah/dotfiles/archbox/utils/ubuntu/ubuntu.sh)"
}
echo "Your OS is $MY_OS"
echo "Your Distro is $MY_DISTRO"
if [ -f $MY_OS = "macOS" ]; then
echo "Your Architecture is $MY_ARCHITECTURE"
fi
if [ -z "${skip_packages}" ] ; then
if [ $MY_OS = "macOS" ]; then
install_macos
elif [ $MY_OS = "Linux" ] && [ $MY_DISTRO = "Arch" ]; then
install_arch
elif [ $MY_OS = "Linux" ] && [ $MY_DISTRO = "Ubuntu" ]; then
install_ubuntu
fi
fi
###############################################################################
# TODO: Installing dotfiles
###############################################################################
function create_dotfiles_path {
if [ ! -d "$1" ]; then
mkdir "$1"
else
echo "$1 directory already exists"
fi
}
# Gets the absolute path of dotfiles_path
read -rep $'\nWhere do you want your dotfiles to live [~/workspaces/dotfiles]? ' dotfiles_path
eval dotfiles_path="${dotfiles_path:-"${HOME}/workspaces/dotfiles"}"
if [ ! $MY_OS = "macOS" ]; then
dotfiles_path=$(realpath $dotfiles_path)
fi
# Clone dotfiles to dotfiles_path
echo "Installing dotfiles to the following directory: $dotfiles_path"
git clone /~https://github.com/abasnfarah/dotfiles "$dotfiles_path"
###############################################################################
# Install Plug (vim plugin manager)
###############################################################################
curl -fLo ${HOME}/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
###############################################################################
# Install tpm (tmux plugin manager)
###############################################################################
git clone /~https://github.com/tmux-plugins/tpm ${HOME}/.tmux/plugins/tpm
###############################################################################
# Create symlinks for dotfiles
###############################################################################
ln -fs "${dotfiles_path}/zsh/zshrc" "${HOME}/.zshrc"
ln -fs "${dotfiles_path}/zsh/local.zsh" "${HOME}/.local.zsh"
ln -fs "${dotfiles_path}/zsh/aliases.zsh" "${HOME}/.aliases.zsh"
ln -fs "${dotfiles_path}/vim/vimrc" "${HOME}/.vimrc"
ln -fs "${dotfiles_path}/tmux/tmux.conf" "${HOME}/.tmux.conf"
ln -fs "${dotfiles_path}/zsh/plugins/plugins.zsh" "${HOME}/.plugins.zsh"
ln -fs "${dotfiles_path}/neovim/nvim" "${HOME}/.config/nvim"
if [ $MY_OS = "Linux" ]; then
mkdir -p "${HOME}/.config/awesome"
mkdir -p "${HOME}/.config/termite"
mkdir -p "${HOME}/.config/alacritty"
ln -fs "${dotfiles_path}/arch/config/awesome/rc.lua" "${HOME}/.config/awesome/rc.lua"
ln -fs "${dotfiles_path}/arch/config/termite/config" "${HOME}/.config/termite/config"
ln -fs "${dotfiles_path}/arch/config/alacritty/alacritty.toml" "${HOME}/.config/alacritty/alacritty.toml"
ln -fs "${dotfiles_path}/arch/.xinitrc" "${HOME}/.xinitrc"
fi
if [ ! -d "${HOME}/.ssh" ]; then
mkdir "${HOME}/.ssh"
fi
ln -fs "${dotfiles_path}/ssh/config" "${HOME}/.ssh/config"
###############################################################################
# Installing awesome WM theme
###############################################################################
# git clone --recurse-submodules --remote-submodules --depth 1 -j 2 /~https://github.com/lcpz/awesome-copycats.git
# mv -bv awesome-copycats/{*,.[^.]*} ~/config/awesome; rm -rf awesome-copycats
###############################################################################
# Installing vim plugins
###############################################################################
echo "Installing Vim Plugins... "
vim -E +PlugInstall +qall || true
###############################################################################
# ur machine is a potato now
###############################################################################
cat << EOF
All dotfiles have been succesfully installed.
To checkout the dotfiles code and other goodies go here:
/~https://github.com/abasnfarah/dotfiles
Time to get cracking!!
EOF
exit 0