-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·185 lines (161 loc) · 4.46 KB
/
bootstrap.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
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
#!/bin/bash
# shellcheck disable=SC2044
# ----------------------------------
# Variables
# ----------------------------------
RED='\033[0;41;30m'
STD='\033[0;0;39m'
DFROOT="$(dirname "$(readlink -f "$0")")"
# ----------------------------------
# Functions
# ----------------------------------
pause() {
echo ""
read -rp "Press any key to continue... " -n1 -s
}
autolinker() {
echo "Auto Symlinking .symc/.symh objects in $1"
if [ -d "$1" ]; then
# Create/Refresh dotfile symlinks (~/.config/*)
mkdir ~/.config &>/dev/null || true
for src in $(find -H "$1" -maxdepth 4 -name '*.symc' -not -path '*.git*'); do
dst="$HOME/.config/$(basename "${src%.*}")"
rm -rf "$dst" &>/dev/null || true
ln -rsf "$src" "$dst"
done
# Create/Refresh dotfile symlinks (~/*)
for src in $(find -H "$1" -maxdepth 4 -name '*.symh' -not -path '*.git*'); do
dst="$HOME/.$(basename "${src%.*}")"
rm -rf "$dst" &>/dev/null || true
ln -rsf "$src" "$dst"
done
echo "Symlinks have been created!"
else
echo -e "${RED}${1} Not Found!!!${STD}"
fi
pause
}
binlinker() {
mkdir -p "$HOME/.local/bin"
for src in $(find -H "$1" -maxdepth 1 -type f); do
dst="$HOME/.local/bin/$(basename "$src")"
rm -rf "$dst" &>/dev/null || true
ln -rsf "$src" "$dst"
done
echo "Symlinks have been created!"
pause
}
gitinfo() {
echo "Setting Default Git Author Name and Email!"
if [ -d "$HOME/.config/git" ]; then
touch "$HOME/.config/git/userinfo"
read -erp 'What is your git author name?: ' git_authorname
read -erp 'What is your git author email?: ' git_authoremail
echo "[user]" >"$HOME/.config/git/userinfo"
echo "name = ${git_authorname}" >>"$HOME/.config/git/userinfo"
echo "email = ${git_authoremail}" >>"$HOME/.config/git/userinfo"
echo "Git User Info Set!"
else
echo -e "${RED}Git User Info NOT Set! CLI Config Files Must Be Linked First!!${STD}"
fi
pause
}
sshinit() {
if [ ! -f ~/.ssh/config ]; then
mkdir ~/.ssh &>/dev/null || true
touch ~/.ssh/config
chmod -R 700 ~/.ssh
echo "AddKeysToAgent yes" >>~/.ssh/config
echo "SSH Directory and Config File Have Been Initialized!"
else
echo -e "${RED}~/.ssh/config already exists! Skipping SSH initialization!!${STD}"
fi
pause
}
ensure_pixi() {
# Ensure Pixi Is Installed/Setup
if ! which --skip-alias --skip-functions pixi &>/dev/null; then
mkdir -p ~/.pixi/bin
curl -fsSL https://pixi.sh/install.sh | PIXI_HOME="$HOME/.pixi" PIXI_NO_PATH_UPDATE="true" bash
fi
export PATH="$HOME/.pixi/bin:$PATH"
}
toolsetup() {
ensure_pixi
pixi global install nvim
pixi global install zellij
pixi global install tmux
pixi global install htop
pixi global install glances
if [ "$1" == "plus-optional" ]; then
pixi global install vim
pixi global install emacs --expose emacs --expose emacsclient
pixi global install helix
pixi global install code-server
pixi global install jq
pixi global install xq
pixi global install yq --expose yq
pixi global install fzf
pixi global install ripgrep
pixi global install just
pixi global install tldr
pixi global install bash-language-server
pixi global install yaml-language-server
pixi global install shellcheck
pixi global install --environment vale vale vale-ls
fi
pause
}
toolupdate() {
ensure_pixi
pixi self-update
pixi global update
pause
}
# function to display menus
show_menus() {
clear
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo " B O O T S T R A P - M E N U"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "1. Link/Relink BIN Files"
echo "2. Link/Relink CLI Config Files"
echo "3. Link/Relink GUI Config FIles"
echo ""
echo "4. Git Default Author/Email"
echo "5. SSH Init (~/.ssh & ~/.ssh/config)"
echo ""
echo "6. Install Required CLI Tools"
echo "7. Install Optional Tools"
echo "8. Update Installed Tools"
echo ""
echo "9. Exit"
}
# read input from the keyboard and take a action
read_options() {
local choice
read -rp "Enter choice [ 1 - 9 ] " choice
case $choice in
1) binlinker "${DFROOT}/BIN" ;;
2) autolinker "${DFROOT}/CLI" ;;
3) autolinker "${DFROOT}/GUI" ;;
4) gitinfo ;;
5) sshinit ;;
6) toolsetup ;;
7) toolsetup "plus-optional" ;;
8) toolupdate ;;
9) exit 0 ;;
*) echo -e "${RED}Error...${STD}" && sleep 2 ;;
esac
}
# ----------------------------------------------
# Trap CTRL+C, CTRL+Z and quit singles
# ----------------------------------------------
trap '' SIGINT SIGQUIT SIGTSTP
# -----------------------------------
# Main logic - infinite loop
# ------------------------------------
while true; do
show_menus
read_options
done