This repository has been archived by the owner on Apr 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
zsh.sh
executable file
·592 lines (588 loc) · 17.9 KB
/
zsh.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
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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
#!/usr/bin/env bash
#################################################
set_tui_bin() {
case $(uname -o) in
"Android") TUI_BIN="dialog" ;;
*) TUI_BIN="whiptail" ;;
esac
}
show_tmoe_zsh_package_info() {
cat <<-EndOfShow
Package: tmoe-zsh
Version: 1.289
Priority: optional
Section: shells
Maintainer: 2moe <[email protected]>
Depends: bat (>= 0.12.1), binutils (>= 2.28-5), curl (>= 7.52.1) | wget (>= 1.18-5), diffutils (>= 1:3.5-3), exa(>= 0.8.0), fzf (>= 0.20.0), git, grep, less, pv (>= 1.6.0), sed (>= 4.4-1), sudo (>= 1.8.19p1-2.1), tar (>= 1.29b-1.1), whiptail (>= 0.52.19), xz-utils (>= 5.2.2), zsh (>= 5.3.0)
Recommends: command-not-found, eatmydata, fonts-powerline, gzip, htop
Suggests: lolcat, micro, neofetch, zstd
Homepage: https://github.com/2cd/zsh
Tag: interface::TODO, interface::shell, interface::text-mode, role::program, works-with::text
Description: Easily configure zsh themes and plugins. Just type "zsh-i" to enjoy it.
EndOfShow
}
################
main() {
terminal_color
case "$1" in
u | up | -u)
tmoe_zsh_preconfigure
upgrade_tmoe_zsh_manager
;;
h | -h | --h | --help) get_tmoe_zsh_help_info ;;
--tmoe_container_auto_configure | --tmoe_container_automatic_configure | --auto)
tmoe_zsh_preconfigure
TMOE_CONTAINER_AUTO_CONFIGURE=true
tmoe_zsh_installation
;;
p | -p | plugin)
tmoe_zsh_preconfigure
tmoe_zsh_plugin_manager
;;
*)
check_tmoe_zsh_file
tmoe_zsh_preconfigure
tmoe_zsh_main_menu
;;
esac
}
################
check_tmoe_zsh_file() {
if [[ ! -s ${HOME}/.config/tmoe-zsh/git/zsh.sh && ${TMOE_ZSH} != true ]]; then
show_tmoe_zsh_package_info
RETURN_TO_WHERE="exit"
do_you_want_to_continue
fi
}
tmoe_zsh_preconfigure() {
set_tui_bin
gnu_linux_env
check_system
}
get_tmoe_zsh_help_info() {
cat <<-'EOF'
u --更新(update tmoe-zsh)
h --get help info
--auto --容器环境自动配置zsh
p -- 插件管理器 plugins manager
EOF
}
###########
terminal_color() {
RED=$(printf '\033[31m')
GREEN=$(printf '\033[32m')
YELLOW=$(printf '\033[33m')
BLUE=$(printf '\033[34m')
PURPLE=$(printf '\033[35m')
CYAN=$(printf '\033[36m')
RESET=$(printf '\033[m')
BOLD=$(printf '\033[1m')
RB_RED=$(printf '\033[38;5;196m')
RB_ORANGE=$(printf '\033[38;5;202m')
RB_YELLOW=$(printf '\033[38;5;226m')
RB_GREEN=$(printf '\033[38;5;082m')
RB_BLUE=$(printf '\033[38;5;021m')
RB_INDIGO=$(printf '\033[38;5;093m')
RB_VIOLET=$(printf '\033[38;5;163m')
}
########
source_tmoe_zsh_env() {
if [ -e "${TMOE_ZSH_TOOL_DIR}/environment" ]; then
source ${TMOE_ZSH_TOOL_DIR}/environment
fi
}
##########
gnu_linux_env() {
TMOE_CONTAINER_AUTO_CONFIGURE=false
if [ -z "${TMPDIR}" ]; then
TMPDIR='/tmp'
fi
TERMUX_PATH="${HOME}/.termux"
TERMUX_KEYBOARD_FILE="${TERMUX_PATH}/termux.properties"
TERMUX_KEYBOARD_BACKUP_FILE="${TMPDIR}/termux.properties.bak"
TERMUX_COLOR_FILE="${TERMUX_PATH}/colors.properties"
TMOE_ZSH_DIR="${HOME}/.config/tmoe-zsh"
TMOE_ZSH_FONTS_PATH="${TMOE_ZSH_DIR}/fonts"
TMOE_ZSH_GIT_DIR="${TMOE_ZSH_DIR}/git"
TMOE_ZSH_TERMUX_PATH="${TMOE_ZSH_DIR}/git/share"
TMOE_ZSH_CONFIG_DIR="${TMOE_ZSH_TERMUX_PATH}/config"
TMOE_ZSH_TOOL_DIR="${TMOE_ZSH_GIT_DIR}/tools"
PLUGIN_SCRIPT="${TMOE_ZSH_TOOL_DIR}/plugins.sh"
RESTORE_SCRIPT="${TMOE_ZSH_TOOL_DIR}/restore.sh"
TMOE_GIT_REPO='https://github.com/2cd/zsh' #此处不包含.git
ZINIT_DIR="${HOME}/.zinit"
ZINIT_THEME_DIR="${ZINIT_DIR}/themes/_local"
ZINIT_SNIPPETS_LOCAL="${ZINIT_DIR}/snippets/_local"
OMZ_DIR="${ZINIT_DIR}/omz"
OMZ_THEME_DIR="${OMZ_DIR}/themes"
CURRENT_DIR=$(pwd)
source_tmoe_zsh_env
if [ ! -e "${TMOE_ZSH_DIR}" ]; then
mkdir -pv ${TMOE_ZSH_DIR}
fi
case $(uname -o) in
Android) LINUX_DISTRO='Android' ;;
GNU/Linux | Linux | linux)
PREFIX='/usr/local'
[[ -d ${PREFIX} ]] || PREFIX='/usr'
check_linux_distro
;;
*)
printf "%s\n" "${RED}ERROR${RESET}, this tool does not support ${BLUE}$(uname -o)${RESET}."
uname -a
exit 1
;;
esac
check_release_version
}
##########
check_system() {
if [ -e "${TMOE_ZSH_GIT_DIR}/.termux/themes.sh" ]; then
cat <<-EOF
You are using ${RED}old version${RESET}.
You need to delete the old version first and then reinstall it.
由于新版改动过大,故不兼容旧版。请删除旧版本!!!
rm -rv ${TMOE_ZSH_GIT_DIR} $(command -v zsh-i)
EOF
do_you_want_to_continue
case $(command -v zsh-i) in
"") rm -rv ${TMOE_ZSH_GIT_DIR} ;;
*) rm -rv ${TMOE_ZSH_GIT_DIR} $(command -v zsh-i) || sudo rm -v $(command -v zsh-i) ;;
esac
fi
case "${LINUX_DISTRO}" in
Android) #check_termux_dependencies
check_termux_git_and_dialog ;;
*) #check_gnu_linux_dependencies
check_gnu_linux_git_and_whiptail ;;
esac
}
###############################
case_return_to_where() {
case ${RETURN_TO_WHERE} in
"") tmoe_zsh_main_menu ;;
*) ${RETURN_TO_WHERE} ;;
esac
}
########################
do_you_want_to_continue() {
printf "%s\n" "${YELLOW}Do you want to continue?[Y/n]${RESET}"
printf "%s\n" "Press ${GREEN}enter${RESET} to ${BLUE}continue${RESET},type ${YELLOW}n${RESET} to ${BLUE}return.${RESET}"
printf "%s\n" "按${GREEN}回车键${RESET}${BLUE}继续${RESET},输${YELLOW}n${RESET}${BLUE}返回${RESET}"
read opt
case $opt in
y* | Y* | "") ;;
n* | N*)
printf "%s\n" "skipped."
case_return_to_where
;;
*)
printf "%s\n" "Invalid choice. skipped."
case_return_to_where
;;
esac
}
################
press_enter_to_continue() {
printf "%s\n" "Press ${GREEN}enter${RESET} to ${BLUE}continue.${RESET}"
printf "%s\n" "按${GREEN}回车键${RESET}${BLUE}继续${RESET}"
read
}
#################
press_enter_to_return() {
printf "%s\n" "Press ${GREEN}enter${RESET} to ${BLUE}return.${RESET}"
printf "%s\n" "按${GREEN}回车键${RESET}${BLUE}返回${RESET}"
read
}
##################
check_release_version() {
case "${LINUX_DISTRO}" in
Android) OSRELEASE="Android" ;;
*)
if grep -q 'NAME=' /etc/os-release; then
OSRELEASE=$(cat /etc/os-release | grep -v 'PRETTY' | grep 'NAME=' | head -n 1 | cut -d '=' -f 2 | cut -d '"' -f 2)
elif grep -q 'ID=' /etc/os-release; then
OSRELEASE=$(cat /etc/os-release | grep -v 'VERSION' | grep 'ID=' | head -n 1 | cut -d '=' -f 2)
else
OSRELEASE=LINUX
fi
;;
esac
}
#####################
openwrt_router_zsh_command() {
printf "%s\n" "本工具已不再支持OpenWRT和Entware"
LINUX_DISTRO='openwrt'
TMOE_UPDATE_COMMAND='opkg update'
TMOE_REMOVAL_COMMAND='opkg remove'
}
############
debian_env() {
LINUX_DISTRO='debian'
TMOE_INSTALLATION_COMMAND='eatmydata apt install -y'
TMOE_INSTALLATION_COMMAND_NON_AUTO='sudo apt install'
TMOE_REMOVAL_COMMAND='apt purge -y'
# TMOE_UPDATE_COMMAND='sudo apt update'
TMOE_UPDATE_COMMAND='apt update'
}
arch_linux_env() {
LINUX_DISTRO='arch'
TMOE_UPDATE_COMMAND='pacman -Syy'
TMOE_INSTALLATION_COMMAND='pacman -Syu --noconfirm --needed'
TMOE_INSTALLATION_COMMAND_NON_AUTO='sudo pacman -Syu --needed'
TMOE_REMOVAL_COMMAND='pacman -Rsc'
}
check_linux_distro_etc_release() {
OS_RELEASE=$(cat /etc/os-release)
case ${OS_RELEASE} in
*debian* | *ubuntu* | *deepin* | *uos.com*)
debian_env
case ${OS_RELEASE} in
*ubuntu*) DEBIAN_DISTRO='ubuntu' ;;
*Kali*) DEBIAN_DISTRO='kali' ;; #"$(cut -c 1-4 /etc/issue)" = "Kali"
*deepin* | *uos.com*) DEBIAN_DISTRO='deepin' ;;
esac
;;
*Arch* | *Manjaro*) arch_linux_env ;;
*Fedora* | *CentOS* | "*Red Hat*" | *redhat* | *fedora*)
LINUX_DISTRO='redhat'
if [ $(command -v dnf) ]; then
TMOE_UPDATE_COMMAND='dnf update'
TMOE_INSTALLATION_COMMAND='dnf install -y --skip-broken'
TMOE_REMOVAL_COMMAND='dnf remove -y'
else
TMOE_UPDATE_COMMAND='yum update'
TMOE_INSTALLATION_COMMAND='yum install -y --skip-broken'
TMOE_REMOVAL_COMMAND='yum remove -y'
fi
case ${OS_RELEASE} in
*Fedora*) REDHAT_DISTRO='fedora' ;;
*ID=*centos* | *rhel*) REDHAT_DISTRO='centos' ;; #"$(grep 'ID=' /etc/os-release | head -n 1 | cut -d '"' -f 2)" = "centos"
esac
;;
*Alpine*)
LINUX_DISTRO='alpine'
TMOE_UPDATE_COMMAND='apk update'
TMOE_INSTALLATION_COMMAND='apk add'
TMOE_REMOVAL_COMMAND='sudo apk del'
;;
*gentoo* | *funtoo*)
LINUX_DISTRO='gentoo'
TMOE_INSTALLATION_COMMAND='emerge -avk'
# TMOE_INSTALLATION_COMMAND_NO_SUDO='emerge -avk'
# TMOE_INSTALLATION_COMMAND_NON_AUTO='sudo emerge -avk'
TMOE_REMOVAL_COMMAND='emerge -C'
;;
*Solus*)
LINUX_DISTRO='solus'
TMOE_INSTALLATION_COMMAND='eopkg install -y'
# TMOE_INSTALLATION_COMMAND_NO_SUDO='eopkg install -y'
# TMOE_INSTALLATION_COMMAND_NON_AUTO='sudo eopkg install'
TMOE_REMOVAL_COMMAND='eopkg remove -y'
;;
*ID=\"void\"*)
LINUX_DISTRO='void'
export LANG='en_US.UTF-8'
TMOE_INSTALLATION_COMMAND='xbps-install -Sy'
TMOE_REMOVAL_COMMAND='xbps-remove -R'
;;
*openSUSE* | *suse*)
LINUX_DISTRO='suse'
TMOE_INSTALLATION_COMMAND='zypper in -y'
TMOE_REMOVAL_COMMAND='zypper rm'
;;
*Slackware*)
LINUX_DISTRO='slackware'
TMOE_UPDATE_COMMAND='slackpkg update'
TMOE_INSTALLATION_COMMAND='slackpkg install'
TMOE_REMOVAL_COMMAND='slackpkg remove'
;;
*openwrt*)
openwrt_router_zsh_command
LINUX_DISTRO='openwrt'
TMOE_UPDATE_COMMAND='opkg update'
TMOE_INSTALLATION_COMMAND='opkg install'
TMOE_REMOVAL_COMMAND='opkg remove'
;;
*) check_linux_distro_pkg_manager ;;
esac
}
check_linux_distro_pkg_manager() {
if [[ $(command -v dpkg) && $(command -v apt-cache) ]]; then
debian_env
elif [[ $(command -v pacman) ]]; then
arch_linux_env
fi
}
check_linux_distro() {
unset TMOE_UPDATE_COMMAND
if [[ -e /etc/os-release ]]; then
check_linux_distro_etc_release
else
check_linux_distro_pkg_manager
fi
}
#################
install_dependencies_01() {
case "${LINUX_DISTRO}" in
debian) ${TMOE_UPDATE_COMMAND} ;;
alpine) apk_update_source_index ;;
esac
######
case $(id -u) in
0) ${TMOE_INSTALLATION_COMMAND} ${DEPENDENCIES} ;;
*)
if [ $(command -v sudo) ]; then
sudo ${TMOE_INSTALLATION_COMMAND} ${DEPENDENCIES} || sudo ${TMOE_INSTALLATION_COMMAND} ${DEPENDENCIES} || su -c "${TMOE_INSTALLATION_COMMAND} ${DEPENDENCIES}"
else
su -c "${TMOE_INSTALLATION_COMMAND} ${DEPENDENCIES}" || su -c "${TMOE_INSTALLATION_COMMAND} ${DEPENDENCIES}" || su -c "${TMOE_INSTALLATION_COMMAND} ${DEPENDENCIES}"
fi
;;
esac
}
###############
install_dependencies_02() {
case $(id -u) in
0)
eatmydata apt update || apt update
eatmydata apt install -y ${DEPENDENCIES} || apt-get install -y ${DEPENDENCIES} || eatmydata apt install -y ${DEPENDENCIES_02} || apt-get install -y ${DEPENDENCIES_02}
;;
*)
if [ $(command -v sudo) ]; then
sudo eatmydata apt update || su -c "apt update"
sudo eatmydata apt install -y ${DEPENDENCIES} || sudo apt install -y ${DEPENDENCIES} || sudo apt install -y ${DEPENDENCIES_02} || su -c "apt install -y ${DEPENDENCIES_02}"
else
su -c "apt update"
su -c "apt install -y ${DEPENDENCIES} || apt install -y ${DEPENDENCIES_02}" || apt-get install -y "${DEPENDENCIES_02}"
fi
;;
esac
}
###############
apk_update_source_index() {
case $(id -u) in
0) apk update ;;
*)
if [ $(command -v sudo) ]; then
sudo apk update
else
su -c "apk update"
fi
;;
esac
}
###########
installing_dependencies() {
printf "%s\n" "Tmoe-zsh will ${YELLOW}install${RESET} relevant ${BLUE}dependencies${RESET} for you."
# printf "%s\n" "即将${YELLOW}安装${RESET}相关${GREEN}软件包${RESET}及其${BLUE}依赖...${RESET}"
printf "%s\n" "${GREEN}${TMOE_INSTALLATION_COMMAND}${BLUE}${DEPENDENCIES}${RESET}"
printf "%s\n" "If you want to ${BOLD}${RED}remove it${RESET}${RESET},please ${YELLOW}manually type ${PURPLE}${TMOE_REMOVAL_COMMAND} ${BLUE}${DEPENDENCIES}${RESET}"
}
###########
check_gnu_linux_git_and_whiptail() {
DEPENDENCIES=""
if [ ! $(command -v bash) ]; then
DEPENDENCIES="${DEPENDENCIES} bash"
fi
#gentoo:app-shells/bash
###########
if [ ! $(command -v git) ]; then
case "${LINUX_DISTRO}" in
openwrt) DEPENDENCIES="${DEPENDENCIES} git git-http" ;;
gentoo) DEPENDENCIES="${DEPENDENCIES} dev-vcs/git" ;;
*) DEPENDENCIES="${DEPENDENCIES} git" ;;
esac
fi
###########
#termux distro-proot中的whiptail为dialog而非whiptail
if [ "$(command -v whiptail)" = "/data/data/com.termux/files/usr/bin/whiptail" ] || [ ! $(command -v whiptail) ]; then
case "${LINUX_DISTRO}" in
debian) DEPENDENCIES="${DEPENDENCIES} whiptail" ;;
arch) DEPENDENCIES="${DEPENDENCIES} libnewt" ;;
gentoo) DEPENDENCIES="${DEPENDENCIES} dev-libs/newt" ;;
openwrt) DEPENDENCIES="${DEPENDENCIES} whiptail dialog" ;;
*) DEPENDENCIES="${DEPENDENCIES} newt" ;;
esac
fi
case "${LINUX_DISTRO}" in
debian)
if (! command -v eatmydata >/dev/null); then
printf "%s\n" "apt install -y eatmydata"
apt update || sudo apt update
apt install -y eatmydata || sudo apt install eatmydata
#DEPENDENCIES="${DEPENDENCIES} eatmydata"
fi
;;
esac
#########
if [ ! -z "${DEPENDENCIES}" ]; then
installing_dependencies
case "${LINUX_DISTRO}" in
debian)
DEPENDENCIES_02='git whiptail'
install_dependencies_02
;;
openwrt)
opkg update
install_dependencies_01 || opkg install ${DEPENDENCIES}
;;
alpine | arch | redhat | void | gentoo | suse | slackware | solus)
install_dependencies_01
;;
*)
printf "%s\n" "${RED}不支持${RESET}您当前的发行版,您可以前往${YELLOW}https://github.com/2cd/zsh${RESET}提交issue,并附上${BLUE}cat /etc/os-release${RESET}的截图。"
press_enter_to_continue
exit 1
# check_root
# apt update
# apt install -y bash git whiptail || port install ${DEPENDENCIES} || guix package -i ${DEPENDENCIES} || pkg install ${DEPENDENCIES} || pkg_add ${DEPENDENCIES} || pkgutil -i ${DEPENDENCIES}
;;
esac
fi
}
####################################################
check_android_termux_whiptail() {
[[ -e ${PREFIX}/bin/whiptail ]] || apt install -y whiptail
}
check_termux_git_and_dialog() {
TMOE_UPDATE_COMMAND='apt update'
TMOE_INSTALLATION_COMMAND='apt install -y'
TMOE_REMOVAL_COMMAND='apt purge -y'
if [ ! -h "/data/data/com.termux/files/home/storage/shared" ]; then
termux-setup-storage
fi
DEPENDENCIES=""
if [ ! -e ${PREFIX}/bin/git ]; then
DEPENDENCIES="${DEPENDENCIES} git"
fi
if [ ! -e ${PREFIX}/bin/whiptail ]; then
DEPENDENCIES="${DEPENDENCIES} dialog"
fi
if [ ! -z "${DEPENDENCIES}" ]; then
installing_dependencies
apt update
apt install -y ${DEPENDENCIES}
fi
check_android_termux_whiptail
}
###############################################
git_clone_tmoe_zsh() {
if [ ! -e "${TMOE_ZSH_GIT_DIR}/.git" ]; then
rm -rvf ${TMOE_ZSH_GIT_DIR} 2>/dev/null
git clone --depth=1 ${TMOE_GIT_REPO} ${TMOE_ZSH_GIT_DIR}
source_tmoe_zsh_env
else
git_pull_tmoe_zsh
fi
}
######################################################
git_pull_tmoe_zsh() {
cd ${TMOE_ZSH_GIT_DIR}
git reset --hard origin/master
git pull --rebase --stat origin master --allow-unrelated-histories || git rebase --skip
case "${?}" in
0) ;;
*)
git fetch --depth=2
git reset --hard
git pull --rebase --stat --allow-unrelated-histories || git rebase --skip
;;
esac
}
###########
tmoe_zsh_main_menu() {
#20 50 7
RETURN_TO_WHERE='tmoe_zsh_main_menu'
# --backtitle "You can select installation for initial installation."
TMOE_OPTION=$("${TUI_BIN:-dialog}" --title "TMOE-ZSH running on ${OSRELEASE}(202105)" --menu "输zsh-i启动本工具,type zsh-i to start this tool.\nPlease use the enter and arrow keys to operate." 0 50 0 \
"1" "🍭 Installation and configuration 安装与配置" \
"2" "🌸 Itemized configuration 分项配置" \
"3" "🍀 Plugins 插件管理" \
"4" "🏫 FAQ 常见问题" \
"5" "💔 Remove zsh 移除" \
"6" "🍹 Backup zsh 备份" \
"7" "🔯 Restore 恢复/还原" \
"8" "🍧 Update 更新" \
"0" "🌚 Exit 退出" \
3>&1 1>&2 2>&3)
#############
case ${TMOE_OPTION} in
0 | "") exit 0 ;;
1) tmoe_zsh_installation ;;
2) tmoe_zsh_itemized_configuration ;;
3) tmoe_zsh_plugin_manager ;;
4) tmoe_zsh_faq ;;
5) tmoe_zsh_uninstallation_menu ;;
6) tmoe_zsh_backup_menu ;;
7) tmoe_zsh_restore_menu ;;
8) upgrade_tmoe_zsh_manager ;;
esac
###############
press_enter_to_return
tmoe_zsh_main_menu
}
######################
check_tmoe_zsh_plugin_script() {
if [ ! -e "${TMOE_ZSH_TOOL_DIR}/environment" ]; then
printf "%s\n" "检测到TMOE配置插件不存在,您需要克隆本项目才能继续使用。"
printf "%s\n" "Do you want to git clone this repo to ${BLUE}${TMOE_ZSH_GIT_DIR}${RESET}"
do_you_want_to_continue
tmoe_zsh_installation
fi
}
##################
tmoe_zsh_installation() {
git_clone_tmoe_zsh
source ${TMOE_ZSH_TOOL_DIR}/install.sh
}
#################
upgrade_tmoe_zsh_manager() {
check_tmoe_zsh_plugin_script
source ${TMOE_ZSH_TOOL_DIR}/update.sh
}
###########
tmoe_zsh_itemized_configuration() {
check_tmoe_zsh_plugin_script
source ${TMOE_ZSH_TOOL_DIR}/itemized_configuration
}
###############
tmoe_zsh_faq() {
source ${TMOE_ZSH_TOOL_DIR}/faq
}
##############
tmoe_zsh_uninstallation_menu() {
source ${TMOE_ZSH_TOOL_DIR}/remove.sh
}
#############
tmoe_zsh_restore_menu() {
check_tmoe_zsh_plugin_script
bash ${RESTORE_SCRIPT}
tmoe_zsh_main_menu
}
###########
tmoe_zsh_backup_menu() {
check_tmoe_zsh_plugin_script
source ${TMOE_ZSH_TOOL_DIR}/backup
}
##############
tmoe_install_batcat() {
if [ ! $(command -v batcat) ] && [ ! $(command -v bat) ] && [ ! -e "${TMOE_ZSH_DIR}/not_install_bat" ]; then
${TMOE_UPDATE_COMMAND} || sudo ${TMOE_UPDATE_COMMAND}
printf "%s\n" "${GREEN}${TMOE_INSTALLATION_COMMAND}${RESET} ${BLUE}bat${RESET}"
${TMOE_INSTALLATION_COMMAND} bat || sudo ${TMOE_INSTALLATION_COMMAND} bat
printf "%s\n" "If you want to remove it,then type ${RED}${TMOE_REMOVAL_COMMAND}${RESET} ${BLUE}bat${RESET}"
fi
if [ ! $(command -v batcat) ] && [ ! $(command -v bat) ]; then
touch "${TMOE_ZSH_DIR}/not_install_bat"
fi
}
###########
tmoe_zsh_plugin_manager() {
tmoe_install_batcat
check_tmoe_zsh_plugin_script
bash ${PLUGIN_SCRIPT}
tmoe_zsh_main_menu
}
##################################################################################
main "$@"
###########################################