-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
425 lines (380 loc) · 11.8 KB
/
Copy pathinstall.sh
File metadata and controls
425 lines (380 loc) · 11.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
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
#!/data/data/com.termux/files/usr/bin/env bash
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
LIB_DIR="$SCRIPT_DIR/lib"
szf="File Size of"
tsize=$(stty size | cut -d ' ' -f 2)
pkgsize=$(apt-cache pkgnames | wc -l)
FILES=(pbanner progress fmenu confzsh)
for f in "${FILES[@]}"; do
if [[ -f "$LIB_DIR/$f" ]]; then
. "$LIB_DIR/$f"
else
echo "Warning: $LIB_DIR/$f not found"
fi
done
# ===== Parse Termux color theme from ~/.termux/colors.properties =====
conf() {
export FZF_DEFAULT_OPTS=""
COLOR_FILE="$HOME/.termux/colors.properties"
if [[ -f "$COLOR_FILE" ]]; then
declare -A color
while IFS='=' read -r key value; do
[[ $key =~ ^#.*$ || -z $key ]] && continue
color[$key]="$value"
done <"$COLOR_FILE"
export FZF_DEFAULT_OPTS="--color=fg:${color[foreground]},bg:${color[background]},hl:${color[color4]},fg+:${color[foreground]},bg+:${color[color0]},hl+:#98c379,prompt:#61afef,pointer:#e5c07b,marker:#56b6c2 --reverse --height=10 --no-info --pointer=' '"
else
export FZF_DEFAULT_OPTS="--color=hl+:#98c379,prompt:#61afef,pointer:#e5c07b,marker:#56b6c2 --reverse --height=10 --no-info --pointer=' '"
fi
}
install_packages() {
# package list
packages=(curl fd figlet ruby boxes gum bat logo-ls eza zsh timg)
echo -e "\n[🔧] Installing required packages...\n"
for pkg in "${packages[@]}"; do
if command -v "$pkg" >/dev/null 2>&1; then
echo "[✔] $pkg already installed"
else
echo "[➕] Installing $pkg ..."
pkg install -y "$pkg"
fi
done
# ---- Python dependencies for tools ----
if command -v python >/dev/null 2>&1; then
if python - <<'EOF' >/dev/null 2>&1
import requests
EOF
then
echo "[✔] Python package 'requests' already installed"
else
echo "[➕] Installing Python package 'requests'..."
if command -v pip >/dev/null 2>&1; then
pip install -q --user requests --no-warn-script-location \
|| python -m pip install --user requests --no-warn-script-location
else
python -m pip install --user requests --no-warn-script-location
fi
# verify install
if python - <<'EOF' >/dev/null 2>&1
import requests
EOF
then
echo "[✔] Python package 'requests' installed successfully"
else
echo "[✘] Failed to install Python package 'requests'"
fi
fi
else
echo "[⚠️] Python not found. Skipping Python dependencies."
fi
# Check for lolcat
if command -v lolcat >/dev/null 2>&1; then
echo "[✔] lolcat already installed"
else
echo "[➕] Installing lolcat via gem..."
gem install lolcat
if command -v lolcat >/dev/null 2>&1; then
echo "[✔] lolcat installed successfully"
else
echo "[✘] lolcat installation failed"
fi
fi
# Download custom figlet font (pixelfont)
FONT_PATH="$PREFIX/share/figlet/pixelfont.flf"
if [[ ! -f "$FONT_PATH" ]]; then
echo "[➕] Downloading pixelfont.flf ..."
curl -L \
https://raw.githubusercontent.com/imegeek/figlet-fonts/master/pixelfont.flf \
-o "$FONT_PATH"
echo "[✔] Font saved to $FONT_PATH"
else
echo "[✔] pixelfont.flf already exists"
fi
# Install Nerd Font (UbuntuMono Nerd Font)
nerdflink="https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/UbuntuMono.zip"
FONT_DIR="$HOME/.termux"
mkdir -p "$FONT_DIR"
TMPDIR=$(mktemp -d)
echo "[➕] Downloading Nerd Font (UbuntuMono)..."
curl -L "$nerdflink" -o "$TMPDIR/UbuntuMono.zip"
echo "[🎨] Installing Nerd Font to $FONT_DIR/font.ttf ..."
unzip -p "$TMPDIR/UbuntuMono.zip" "UbuntuMonoNerdFontMono-Regular.ttf" >"$FONT_DIR/font.ttf"
rm -rf "$TMPDIR"
echo "[✔] Nerd Font installed at $FONT_DIR/font.ttf"
echo "[ℹ] Restart Termux app to apply new font."# Demo text with lolcat if available
echo -e "\n[🎨] Demo text:\n"
if command -v lolcat >/dev/null 2>&1; then
echo "Installed!" | figlet -f pixelfont | lolcat
else
echo "lolcat not Installed!" | figlet -f pixelfont
fi
# chsh -s zsh
# termux-reload-settings
}
# Run function
menu_main() {
while true; do
conf
banner > ${user}
cat "${user}"
echo ""
choice=$(
printf "1. Install packages\n2. Setup\n3. Exit" |
fzf --prompt="Use ↑/↓ to navigate, Enter to select: " --exit-0
)
case $choice in
"1. Install packages")
echo -e "\033[1;32m[✔] Installing packages...\033[0m"
install_packages
sleep 1
;;
"2. Setup")
menu_setup
;;
"3. Exit")
echo -e "\033[1;31m[✘] Exiting...\033[0m"
break
;;
*)
break
;;
esac
done
}
menu_setup() {
choice=$(
printf "1. Zsh\n2. Fish (coming soon)" |
sed 's/2\. Fish (coming soon)/2. Fish \x1b[31m(\x1b[33mcoming soon\x1b[31m)\x1b[0m/' |
fzf --prompt="Setup option ➤ " --ansi --exit-0
)
case $choice in
"1. Zsh")
menu_zsh_setup
# echo -e "\033[1;34m[ℹ] Setting up Zsh...\033[0m"
sleep 1
;;
"2. Fish (coming soon)")
echo -e "\033[1;33m[⚠] Fish setup is coming soon!\033[0m"
sleep 1
;;
esac
}
menu_zsh_setup() {
# Check if oh-my-zsh is installed
if [[ ! -d "$HOME/.oh-my-zsh" ]]; then
# Not installed → only show setup option
local subchoice
subchoice=$(
printf "1. Install Oh-my-zsh" |
fzf --prompt="Zsh Setup ➤ " --ansi --exit-0
)
case $subchoice in
"1. Install Oh-my-zsh")
echo -e "\033[1;32m[✔] Installing Oh-my-zsh...\033[0m"
install_oh_my_zsh
chsh -s zsh
;;
esac
else
# Already installed → show main options
local main_options="1. Oh-my-zsh (Plugins Manager)\n2. Theader setup"
local subchoice
subchoice=$(
printf "%b" "$main_options" |
fzf --prompt="Zsh Options ➤ " --ansi --exit-0
)
case $subchoice in
"1. Oh-my-zsh (Plugins Manager)")
# Plugins Manager submenu
local plugin_line
plugin_line=$(sed -n 's/^plugins=(\(.*\))/\1/p' "$ZSHRC" | tr -d ' ')
local pm_options="1. Add Zsh Plugins"
# Show remove option only if plugins exist
if [[ -n "$plugin_line" ]]; then
pm_options+="\n2. Remove Plugins"
fi
local pm_choice
pm_choice=$(
printf "%b" "$pm_options" |
fzf --prompt="Plugins Manager ➤ " --ansi --exit-0
)
case $pm_choice in
"1. Add Zsh Plugins")
echo -e "\033[1;34m[ℹ] Opening Add Plugins...\033[0m"
fzf_add_plugin
;;
"2. Remove Plugins")
echo -e "\033[1;31m[⚠] Removing Zsh Plugins...\033[0m"
remove_zsh_plugin
;;
esac
;;
"2. Theader setup")
echo -e "\033[1;36m[ℹ] Running Theader setup...\033[0m"
# Your Theader setup logic
menu_theader_setup
;;
esac
fi
}
# t-header setup
menu_theader_setup() {
local theader_dir="$HOME/.config/theader"
# Check if Theader is installed (directory exists)
if [[ ! -d "$theader_dir" ]]; then
# Not installed → only show setup option
local subchoice
subchoice=$(
printf "1. Setup Theader" |
fzf --prompt="Theader Setup ➤ " --ansi --exit-0
)
case $subchoice in
"1. Setup Theader")
echo -e "\033[1;32m[✔] Setting up Theader...\033[0m"
setup_theader
;;
esac
else
# Already installed → show options
local main_options="1. Change Logo\n2. Change Title\n3. Change Keyboard\n4. Change ZSH Theme\n5. Remove Theader"
local subchoice
subchoice=$(
printf "%b" "$main_options" |
fzf --prompt="Theader Options ➤ " --ansi --exit-0
)
case $subchoice in
"1. Change Logo")
echo -e "\033[1;34m[ℹ] Changing Logo...\033[0m"
c_logo
;;
"2. Change Title")
echo -e "\033[1;34m[ℹ] Changing Title...\033[0m"
type_title
;;
"3. Change Keyboard")
echo -e "\033[1;34m[ℹ] Changing Keyboard Layout...\033[0m"
key_properties
;;
"4. Change ZSH Theme")
echo -e "\033[1;34m[ℹ] Changing ZSH Theme...\033[0m"
c_theme
;;
"5. Remove Theader")
echo -e "\033[1;31m[⚠] Removing Theader...\033[0m"
remove_theader
;;
esac
fi
}
# theader setup function
setup_theader() {
theader_dir="$HOME/.config/theader"
TEMPLATE="$ZSH/templates/zshrc.zsh-template"
if [ -f "$ZSHRC" ]; then
line_count=$(wc -l <"$ZSHRC")
line_104=$(sed -n '104p' "$ZSHRC")
if [ "$line_count" -gt 104 ] && [[ "$line_104" != *"oh-my-zsh"* ]]; then
echo "⚠️ .zshrc has $line_count lines and line 104 lacks 'oh-my-zsh', creating backup..."
cp "$ZSHRC" "$ZSHRC.backup.$(date +%Y%m%d%H%M%S)"
old_plugins=$(grep "^plugins=" "$ZSHRC" | head -n1)
if [ -n "$old_plugins" ]; then
echo "🔗 Found old plugins: $old_plugins"
# template copy
cp "$TEMPLATE" "$ZSHRC"
# template plugins replace
sed -i "s/^plugins=(git)/$old_plugins/" "$ZSHRC"
echo "✅ New .zshrc created with preserved plugins"
else
echo "⚠️ No plugins line found in old .zshrc, using default"
cp "$TEMPLATE" "$ZSHRC"
fi
else
echo ".zshrc has $line_count lines or already contains 'oh-my-zsh' at line 104, no reset needed."
fi
else
cp "$TEMPLATE" "$ZSHRC"
sed -i 's/plugins=(git)/plugins=()/' "$ZSHRC"
echo "✅ Default .zshrc created"
fi
create_custom_theme
change_zsh_theme "unstop"
cp $SCRIPT_DIR/dotfile/.* $HOME/
printf "HISTSIZE=100000\nSAVEHIST=100000\nexport USER=\$(whoami)\nbanner >> \"\${user}\"\ncat \"\${user}\"" >>"$HOME/.zshrc"
printf "\n# profile source\nsource \"\$HOME/.profile\"" >> "$HOME/.zprofile"
mkdir -p "$theader_dir"
for d in bin logo tpt lib theader.cfg; do
if [[ -e "$SCRIPT_DIR/$d" ]]; then
cp -r "$SCRIPT_DIR/$d" "$theader_dir/"
else
echo "Warning: missing $SCRIPT_DIR/$d"
fi
done
if [[ -f $SCRIPT_DIR/colors.properties ]]; then
cp -r $SCRIPT_DIR/colors.properties $HOME/.termux/
fi
if [[ -f $theader_dir/bin/theader ]]; then
install -Dm700 $theader_dir/bin/theader "$PREFIX"/bin/theader
for i in clogo ctitle ctpro cztheme; do
ln -sfr "$PREFIX"/bin/theader "$PREFIX"/bin/$i
done
echo "theader installed successfully ✅"
else
echo "Error: $theader_dir/bin/theader not found!"
fi
# Install commit tool (ac / cak)
mkdir -p "$PREFIX/bin"
TOOL_SRC="$SCRIPT_DIR/tools/commit.py"
TOOL_DST="$PREFIX/bin/ac"
if [[ -f "$TOOL_SRC" ]]; then
install -Dm700 "$TOOL_SRC" "$TOOL_DST" || {
echo "[✘] Failed to install ac"
return 1
}
echo "✅ ac installed to $TOOL_DST"
else
echo "[✘] Missing $TOOL_SRC"
return 1
fi
# change-api-key helper
rm -f "$PREFIX/bin/cak"
ln -sfr "$TOOL_DST" "$PREFIX/bin/cak"
# refresh shell command cache
hash -r 2>/dev/null || true
}
# packages list must above 2000
if ((pkgsize < 2000)); then
echo -ne "\033[31m\r[*] \033[4;32mPackage Update and Upgrade or change repo \e[0m\n"
exit 1
fi
# ✅ Check fzf installed or not
if ! command -v fzf >/dev/null 2>&1; then
echo -e "\033[31m[*] \033[4;32mfzf command not found!\033[0m"
echo -e "\033[1;33mThis tool requires fzf to continue.\033[0m"
read -r -p "👉 Install fzf now? [Y/n]: " ans
# normalize input to lowercase
ans="${ans,,}"
case "$ans" in
y|yes)
echo "[➕] Installing fzf..."
pkg install -y fzf
if command -v fzf >/dev/null 2>&1; then
echo "[✔] fzf installed successfully."
else
echo "[✘] fzf installation failed. Please install manually:"
echo " pkg install fzf -y"
exit 1
fi
;;
n|no)
echo "🚫 Installation cancelled by user."
echo "👉 You can install later with: pkg install fzf -y"
exit 1
;;
*)
echo "[✘] Invalid choice. Please answer y or n."
exit 1
;;
esac
fi
# Run main menu
menu_main