-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
249 lines (216 loc) Β· 8.34 KB
/
install.sh
File metadata and controls
249 lines (216 loc) Β· 8.34 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
#!/bin/bash
# Configuration
ERROR_LOG="$HOME/skip_errors.log"
THEME_DIR=""
THEME_NAME=""
COLUMNS=$(tput cols)
MAX_RETRIES=3
# Color Variables
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
WHITE='\033[0;37m'
BOLD='\033[1m'
RESET='\033[0m'
# Spinner and ASCII Art Colors
ART_COLOR=$CYAN
SPINNER_COLOR=$MAGENTA
# Error handling
log_error() {
echo -e "[$(date +'%Y-%m-%d %H:%M:%S')] ERROR: $1" >> "$ERROR_LOG"
}
# Output functions
status_msg() {
local msg=$1
local status=$2
local symbol_color=$([ "$status" == "β" ] && echo "$GREEN" || echo "$RED")
local clean_msg=$(echo -e "$msg" | sed 's/\x1B\[[0-9;]*[a-zA-Z]//g')
local padding=$((COLUMNS - ${#clean_msg} - 12))
printf "\r%b[ %s ]%b %b%-${padding}s\n" "$symbol_color" "$status" "$RESET" "$msg" ""
}
spinner() {
local pid=$1 msg="$2"
local spin=('β ' 'β ' 'β Ή' 'β Έ' 'β Ό' 'β ΄' 'β ¦' 'β §' 'β ' 'β ')
while kill -0 $pid 2>/dev/null; do
for c in "${spin[@]}"; do
printf "\r%b[%s]%b %b" "$SPINNER_COLOR" "$c" "$RESET" "$msg"
sleep 0.1
done
done
wait $pid
}
run_task() {
local msg="$1"
shift
("$@") > /dev/null 2>> "$ERROR_LOG" &
local pid=$!
spinner $pid "$msg"
local exit_code=$?
status_msg "$msg" "$([ $exit_code -eq 0 ] && echo 'β' || echo 'β')"
}
# Network check
check_network() {
echo -e "${CYAN}Checking network connectivity...${RESET}"
if ! ping -c 1 8.8.8.8 >/dev/null 2>&1; then
echo -e "${RED}No internet connection detected!${RESET}"
echo -e "${YELLOW}Please check your network and try again.${RESET}"
exit 1
fi
}
# Fix Termux repositories
fix_termux_repos() {
echo -e "${YELLOW}Fixing Termux repository configuration...${RESET}"
# Backup current sources
[ -f "$PREFIX/etc/apt/sources.list" ] && \
cp "$PREFIX/etc/apt/sources.list" "$PREFIX/etc/apt/sources.list.backup"
# Use official mirrors
cat > "$PREFIX/etc/apt/sources.list" << 'EOF'
# Main Termux repository (Official mirrors)
deb https://packages.termux.dev/apt/termux-main stable main
EOF
run_task "${BLUE}Updating repository information${RESET}" apt update
}
# Theme selection
select_theme() {
while true; do
clear
echo -e "${ART_COLOR}"
cat << "EOF"
ββββββββββββ βββββββββββββββββββββββ ββββββββββββ
ββββββββββββ ββββββββββββββββββββββββ βββββββββββββ
βββ ββββββββββββββ ββββββ βββββββββββββββββ
βββ ββββββββββββββ ββββββ βββββββββββββββββ
βββ βββ ββββββββββββββββββββββ βββ βββββββββββ
βββ βββ ββββββββββββββββββββββ βββββββββββ
EOF
echo -e "${RESET}"
echo -e "${CYAN} ${BOLD}1) Black Theme${RESET}"
echo -e "${CYAN} ${BOLD}2) Color Theme${RESET}"
echo -e "${RED} ${BOLD}3) Uninstall${RESET}"
echo -e "${YELLOW} ${BOLD}4) Exit${RESET}"
echo
read -p "$(echo -e "${BOLD}${MAGENTA}Select theme (1-4): ${RESET}")" choice
case "$choice" in
1) THEME_DIR="black"; return 0 ;;
2) THEME_DIR="color"; return 0 ;;
3) uninstall_theme; exit 0 ;;
4) echo -e "${RED}Exiting...${RESET}"; exit 0 ;;
*) echo -e "${RED}Invalid option. Please enter 1-4.${RESET}"; sleep 1 ;;
esac
done
}
# Installation tasks
install_packages() {
echo -e ""
echo -e "${RED} ${BOLD}β’β’β’It will take 10-20minβ’β’β’${RESET}"
echo -e "${BOLD}----------------------------${RESET}"
echo -e ""
fix_termux_repos
run_task "${YELLOW}Updating packages${RESET}" apt update
run_task "${YELLOW}Upgrading system${RESET}" apt upgrade -y
run_task "${BLUE}Installing core utilities${RESET}" pkg install zsh git wget curl python figlet lsd logo-ls ncurses-utils -y
run_task "${BLUE}Installing development tools${RESET}" pkg install neovim lua-language-server ripgrep lazygit -y
run_task "${BLUE}Installing figlet and lolcat${RESET}" pkg install figlet ruby -y
run_task "${BLUE}Installing niovim tool${RESET}" apt install build-essential zip termux-api gdu gdb gdbserver gh fd fzf neovim lua-language-server jq-lsp luarocks stylua ripgrep yarn python-pip ccls clang zig rust-analyzer -y
run_task "${BLUE}Installing neovim${RESET}" pip install neovim
run_task "${BLUE}Installing nmp neovim${RESET}" npm install -g neovim
run_task "${BLUE}Installing gem neovim${RESET}" gem install neovim
run_task "${BLUE}Installing lolcat gem (for animation support)${RESET}" gem install lolcat
}
setup_fonts() {
mkdir -p ~/.termux
run_task "${MAGENTA}Setting up fonts${RESET}" cp -f "$HOME/Tmx-theme/src/font.ttf" ~/.termux/
if [ -f "$HOME/Tmx-theme/src/ASCII-Shadow.flf" ]; then
cp -f "$HOME/Tmx-theme/src/ASCII-Shadow.flf" "$PREFIX/share/figlet/"
fi
}
setup_color() {
local config_color=(
".p10k.zsh"
)
for file in "${config_color[@]}"; do
run_task "${BLUE}Configuring ${file}${RESET}" cp -f "$HOME/Tmx-theme/$THEME_DIR/${file##*/}" "$HOME/$file"
done
}
setup_configs() {
local config_files=(
".termux/termux.properties"
".termux/colors.properties"
".termux/font.ttf"
".zshrc"
".banner.sh"
".draw"
".draw.sh"
"../usr/etc/zshrc"
)
for file in "${config_files[@]}"; do
run_task "${BLUE}Configuring ${file}${RESET}" cp -f "$HOME/Tmx-theme/src/${file##*/}" "$HOME/$file"
done
}
setup_zsh_plugins() {
# Install Oh My Zsh core
if [ ! -d ~/.oh-my-zsh/.git ]; then
run_task "${CYAN}Installing Oh My Zsh${RESET}" \
git clone --depth 1 "https://github.com/ohmyzsh/ohmyzsh.git" ~/.oh-my-zsh
fi
# Create required directories
mkdir -p ~/.oh-my-zsh/{plugins,custom/themes}
mkdir -p $PREFIX/etc/.plugin
# Install Powerlevel10k theme
if [ ! -d ~/.oh-my-zsh/custom/themes/powerlevel10k ]; then
run_task "${CYAN}Installing Powerlevel10k${RESET}" \
git clone --depth 1 "https://github.com/romkatv/powerlevel10k.git" \
~/.oh-my-zsh/custom/themes/powerlevel10k
fi
# Standard plugins
local ohmyzsh_plugins=(
"zsh-users/zsh-completions"
"zsh-users/zsh-history-substring-search"
"bobthecow/git-flow-completion"
)
# System-wide plugins
local etc_plugins=(
"zsh-users/zsh-syntax-highlighting"
"zsh-users/zsh-autosuggestions"
)
# Install Oh My Zsh plugins
for plugin in "${ohmyzsh_plugins[@]}"; do
local name=${plugin##*/}
local target_dir="$HOME/.oh-my-zsh/plugins/$name"
[ -d "$target_dir" ] || run_task "${CYAN}Installing ${name}${RESET}" \
git clone --depth 1 "https://github.com/$plugin" "$target_dir"
done
# Install system plugins
for plugin in "${etc_plugins[@]}"; do
local name=${plugin##*/}
local target_dir="$PREFIX/etc/.plugin/$name"
[ -d "$target_dir" ] || run_task "${CYAN}Installing ${name}${RESET}" \
git clone --depth 1 "https://github.com/$plugin" "$target_dir"
done
}
setup_astronvim() {
[ -d ~/.config/nvim ] && run_task "${RED}Removing old nvim config${RESET}" rm -rf ~/.config/nvim
run_task "${GREEN}Installing AstroNvim${RESET}" git clone --depth 1 "https://github.com/tharindu899/Astronvim-Termux.git" ~/.config/nvim
}
uninstall_theme() {
echo -e "${RED}Uninstalling theme...${RESET}"
rm -rf ~/.termux ~/.zshrc ~/.p10k.zsh ~/.banner.sh ~/.oh-my-zsh ~/.config/nvim
termux-reload-settings
echo -e "${GREEN}Theme uninstalled successfully.${RESET}"
}
# Main execution
check_network
select_theme
install_packages
setup_fonts
setup_color
setup_configs
termux-reload-settings
setup_zsh_plugins
setup_astronvim
# Final step
run_task "${BOLD}Setting default shell${RESET}" chsh -s zsh
echo -e "\n${BOLD}${GREEN}β Setup complete! Restart your terminal or run 'zsh'.${RESET}"