-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_termux.sh
More file actions
257 lines (219 loc) · 7.06 KB
/
setup_termux.sh
File metadata and controls
257 lines (219 loc) · 7.06 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
#!/data/data/com.termux/files/usr/bin/bash
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NONE='\033[0m'
_command_exists() {
package="$1"
if ! type "$package" >/dev/null 2>&1; then
echo -e "$RED"
echo ":: ERROR: $package doesn't exist. Please install it with pkg install $2"
echo -e "$NONE"
return 1
fi
return 0
}
_install_package() {
local arg="$1"
local binary pkg_name
if [[ "$arg" == *:* ]]; then
binary="${arg%%:*}"
pkg_name="${arg##*:}"
else
binary="$arg"
pkg_name="$arg"
fi
if ! command -v "$binary" >/dev/null 2>&1; then
if ! gum spin --spinner pulse --title "Installing $pkg_name..." -- pkg install -y "$pkg_name"; then
echo -e "$RED"
echo "Failed to install $pkg_name. Please check for errors and try again."
echo -e "$NONE"
exit 1
fi
else
echo -e "$YELLOW:: $pkg_name is already installed$NONE"
fi
}
echo -e "$GREEN"
cat <<"EOF"
░▀█▀░█▀▀░█▀▄░█▄█░█░█░█░█
░░█░░█▀▀░█▀▄░█░█░█░█░▄▀▄
░░▀░░▀▀▀░▀░▀░▀░▀░▀▀▀░▀░▀
EOF
echo
echo -e "$NONE"
echo ":: Synchronizing package databases..."
pkg update && pkg upgrade -y
dependencies=(
"curl"
"git"
)
echo ":: Installing essential dependencies..."
if ! _command_exists "gum"; then
pkg install -y gum
fi
for dependency in "${dependencies[@]}"; do
_install_package "$dependency"
done
if [ ! -d "$HOME/storage" ]; then
gum spin --spinner dot --title "Setting up storage..." -- termux-setup-storage
fi
packages=(
"bat"
"eza"
"fastfetch"
"fd"
"ffmpeg"
"fzf"
"go:golang"
"jq"
"just"
"lua5.3:lua53"
"make"
"mandoc"
"nvim:neovim"
"node:nodejs"
"python"
"ruff"
"rustc:rust"
"rust-analyzer"
"tree-sitter"
"unzip"
"uv"
"wget"
"yazi"
"zsh"
"zoxide"
)
echo ":: Installing development packages..."
for package in "${packages[@]}"; do
_install_package "$package"
done
gum spin --spinner pulse --title "Enabling pnpm..." -- corepack enable pnpm
gum spin --spinner dot --title "Installing yt-dlp..." -- python3 -m pip install -U --pre "yt-dlp[default]"
gum spin --spinner dot --title "Updating PATH for installed apps..." -- termux-fix-shebang /data/data/com.termux/files/usr/bin/*
echo ":: Setting up oh-my-zsh and plugins..."
if [ ! -d "$HOME/.oh-my-zsh" ]; then
gum spin --spinner pulse --title "Installing oh-my-zsh..." -- sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
if [ ! -d "$ZSH_CUSTOM/themes/powerlevel10k" ]; then
gum spin --spinner dot --title "Installing powerlevel10k theme..." -- git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$ZSH_CUSTOM/themes/powerlevel10k"
fi
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-autocomplete" ]; then
gum spin --spinner dot --title "Installing zsh-autocomplete..." -- git clone --depth=1 https://github.com/marlonrichert/zsh-autocomplete.git "$ZSH_CUSTOM/plugins/zsh-autocomplete"
fi
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]; then
gum spin --spinner dot --title "Installing zsh-autosuggestions..." -- git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "$ZSH_CUSTOM/plugins/zsh-autosuggestions"
fi
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]; then
gum spin --spinner pulse --title "Installing zsh-syntax-highlighting..." -- git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
fi
gum spin --spinner dot --title "Configuring .zshrc..." -- true
cat >~/.zshrc <<'EOF'
HISTORY_IGNORE="(ls|cd|pwd|zsh|exit|cd ..)"
HISTSIZE=10000
SAVEHIST=10000
LISTMAX=1000
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="powerlevel10k/powerlevel10k"
zstyle ':omz:update' mode auto
zstyle ':omz:update' frequency 13
plugins=(git zsh-autocomplete zsh-autosuggestions zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
export EDITOR='nvim'
alias c='clear'
alias cd='z'
alias cat='bat'
alias -s git='git clone'
alias ls='eza'
alias l='eza --icons'
alias ll='eza -l --icons'
alias la='eza -la --icons'
alias reload='exec zsh -l'
alias tree='eza -T --icons --level=2'
alias v=$EDITOR
alias wget='wget -c'
alias x='exit'
alias upgrade='pkg update && pkg upgrade -y'
alias pku='pkg update && pkg upgrade -y'
eval "$(zoxide init zsh)"
source <(fzf --zsh)
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
bindkey -M vicmd ":" undefined-key
function take() {
mkdir -p $1
cd $1
}
# Up, the Plugin
# Author: Peter Hurford
# https://github.com/peterhurford/up.zsh
function up(){ # Go up X directories (default 1)
if [[ "$#" -ne 1 ]]; then
cd ..
elif ! [[ $1 =~ '^[0-9]+$' ]]; then
echo "Error: up should be called with the number of directories to go up. The default is 1."
else
local d=""
limit=$1
for ((i=1 ; i <= limit ; i++))
do
d=$d/..
done
d=$(echo $d | sed 's/^\///')
cd $d
fi
}
function yy() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
yazi "$@" --cwd-file="$tmp"
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
cd "$cwd"
fi
rm -f -- "$tmp"
}
EOF
gum spin --spinner dot --title "Configuring Termux properties..." -- true
mkdir -p ~/.termux
cat >~/.termux/termux.properties <<'EOF'
extra-keys = [[ \
{key: 'ESC', popup: {macro: 'ESC :: q ENTER', display: ':q'}}, \
{key: '/', popup: 'BACKSLASH'}, \
{key: '-', popup: "|"}, \
{key: 'HOME', popup: '~'}, \
'UP', \
{key: 'END', popup: {macro: 'ESC :: w q ENTER', display: ':wq'}}, \
{key: 'KEYBOARD', popup: 'DRAWER'} \
], [ \
'TAB', \
'CTRL', \
'ALT', \
'LEFT', \
'DOWN', \
'RIGHT', \
{key: 'ENTER', popup: {macro: ' ESC :: w ENTER', display: ':w'}} \
]]
EOF
gum spin --spinner dot --title "Configuring fastfetch..." -- mkdir -p "$HOME/.config/fastfetch" && curl -fsSL "https://raw.githubusercontent.com/joncrangle/.dotfiles/main/dot_config/fastfetch/config.jsonc" -o "$HOME/.config/fastfetch/config.jsonc"
gum spin --spinner pulse --title "Setting zsh as default shell..." -- chsh -s "$(which zsh)"
echo
echo -e "$GREEN"
cat <<"EOF"
┌─────────────────────────────────────┐
│ Setup Complete! │
└─────────────────────────────────────┘
EOF
echo
echo "🎉 Your Termux environment is ready!"
echo "⚡ Run 'p10k configure' to customize your prompt theme"
echo "📱 Please ensure that Termux:API and Termux:Styling are installed using F-Droid"
echo "👑 Long press anywhere in Termux, select More -> Styling to select a font and colorscheme"
echo "🖊️ Time to import your Neovim config"
echo
echo -e "$NONE"