-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·195 lines (167 loc) · 4.8 KB
/
install
File metadata and controls
executable file
·195 lines (167 loc) · 4.8 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
# Script to bootstrap my dev environment. This installs required tools and sets
# up various dotfiles. This also assumes it is a barebones Linux machine with
# bash available.
# It does the following -
# - Install required software packages for development (e.g. zsh, tmux, vim, git
# etc.)
# - Create symlinks. The standard config files/dotfiles in $HOME are symlinked
# to files in this # repo.
set -euo pipefail
# Core requirements for my environ
CORE_REQUIREMENTS=(
git
alacritty
zsh
openssh
tmux
tmuxp
htop
tree
bat
neovim
emacs
ripgrep
fd
fzf
ttf-iosevka-nerd
)
is_installed() {
req="$1"
if $(pacman -Qi "$req" > /dev/null); then # if found
return 0
else
return 1
fi
}
check_core_requirements() {
for req in "${CORE_REQUIREMENTS[@]}"
do
echo "Check if $req is installed.."
if ! $(is_installed "$req"); then
echo "$req is not installed; adding to to_install"
to_install=( "${to_install[@]}" $req )
fi
done
if [[ -z "${to_install[@]}" ]]; then
echo "All requirements satisfy.."
return 0
else
return 1
fi
}
check_package_manager() {
# Check if current system is Arch-based; if not, abort
if $(is_installed pacman); then # arch-based distro
return 0;
else
echo "Oops, not an Arch-based system! Currently on Arch-based distros are supported."
echo "Feel free to submit a PR, if you want to add new support."
exit 1
fi
}
install_core_requirements() {
check_package_manager
packages=(${to_install[@]})
echo "Packages to be insalled: ${packages[@]}"
read -p "Continue? [y/N]: "
if [ "$REPLY" != "y" ]; then
echo "Installation aborted."
exit 0
fi
echo "sudo pacman -S ${packages[@]}"
sudo pacman -S --noconfirm ${packages[@]}
}
create_symlinks() {
local dotfiles="$HOME/dotfiles"
mkdir -p "$HOME/.stack/templates"
echo "Creating symlinks for necessary files..."
declare -A symlinks=(
# Alacritty
["$dotfiles/alacritty/alacritty.toml"]="$HOME/.config/alacritty.toml"
# Doom Emacs
["$dotfiles/doom.d"]="$HOME/.doom.d"
# ~Vim~ - Disabling vim for now
#["$dotfiles/vim"]="$HOME/.vim"
#["$dotfiles/vim/vimrc"]="$HOME/.vimrc"
# Neovim
["$dotfiles/neovim"]="$HOME/.config/nvim"
# Zsh
# ["$dotfiles/zsh/omz_zshrc.zsh"]="$HOME/.zshrc"
["$dotfiles/zsh/zinit_zshrc.zsh"]="$HOME/.zshrc"
["$dotfiles/zsh/zshenv"]="$HOME/.zshenv"
# Tmux
["$dotfiles/tmux/tmux.conf"]="$HOME/.tmux.conf"
["$dotfiles/tmux/tmuxp"]="$HOME/.tmuxp"
# Git
["$dotfiles/git/gitconfig"]="$HOME/.gitconfig"
# Shell
["$dotfiles/shell/aliases"]="$HOME/.aliases"
# Haskell Stack
["$dotfiles/stack/config.yaml"]="$HOME/.stack/config.yaml"
["$dotfiles/stack/anonray.hsfiles"]="$HOME/.stack/templates/anonray.hsfiles"
)
for src in "${!symlinks[@]}"; do
local target="${symlinks[$src]}"
echo "Linking: $src → $target"
ln -sf "$src" "$target"
done
}
# install extra tools that are not in the package manager; git clone and install step..
install_from_git_repo() {
name="$1"
repo_url="$2"
clone_dir="$3"
if [[ -z "$name" || -z "$repo_url" || -z "$clone_dir" ]]; then
echo "WARN: Not all required arguments are passed to $0"
echo "WARN: Skipping git clone..."
return;
fi
echo "Cloning $name.."
git clone --depth 1 "$repo_url" "$clone_dir"
}
DOOM_EMACS_DIR="$HOME/.emacs.d"
install_doom_emacs() {
echo "Installing doom emacs..."
install_from_git_repo "doom emacs" "https://github.com/doomemacs/doomemacs" ${DOOM_EMACS_DIR}
echo "Setting up doom emacs..."
sleep 1
echo "Please note, setting up and installing all doom packages will take a while. Go grab a coffee, take a break, and so on!"
~/.emacs.d/bin/doom sync
}
ALACRITTY_THEMES_DIR="$HOME/.config/alacritty/themes"
install_alacritty_themes() {
echo "Installing alacritty themes..."
install_from_git_repo "alacritty themes" "https://github.com/alacritty/alacritty-theme" ${ALACRITTY_THEMES_DIR}
}
set_zsh_default() {
echo "Setting zsh to be default shell.."
sudo chsh -s "$(which zsh)" "$(whoami)"
}
# main install function
install() {
# Step 1: install core requirements..
if ! check_core_requirements; then
echo "Installing core requirements.."
install_core_requirements
fi
# Step 2: check and set zsh to be default shell
if [[ "$SHELL" != *zsh* ]]; then
echo "Zsh is not default shell. Setting.."
set_zsh_default
fi
# Step 3: setup the symlinks..
create_symlinks
# Step 4: manual install of alacritty themes..
if [[ ! -d ${ALACRITTY_THEMES_DIR} ]]; then
echo "Alacritty themes not installed, installing..."
install_alacritty_themes
fi
# Step 5: manual install of doom emacs..
if [[ ! -d ${DOOM_EMACS_DIR} ]]; then
echo "Doom emacs not installed, installing..."
install_doom_emacs
fi
echo "Done"
}
install