-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
51 lines (49 loc) · 1.76 KB
/
uninstall.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
#!/usr/bin/env bash
dotfileDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# shellcheck source=./config.sh
source "${dotfileDir}/config.sh"
# dotfile cmds guis pythons uninstall
for arg in "$@"
do
echo "$arg"
if set | grep -q "^$arg"; then
case $arg in
"cmds")
# 终端所需命令下载
for cmd in "${cmds[@]}"; do
if brew list | grep -q "^${cmd%% *}$"; then
echo "${cmd%% *} ...准备卸载"
brew remove "${cmd}"
fi
done
;;
"guis")
# gui 软件下载
for gui in "${guis[@]}"; do
if brew list --cask | grep -q "^${gui}$"; then
echo "${gui%% *} ...准备卸载"
brew cask zap "${gui}"
fi
done
;;
"pythons") echo "four";;
"dotfiles")
# 匹配的进行删除
# [#%] 尽可能短的从[左右]往[右左]删除字符
# (##|%%) 尽可能长的从[左右]往[右左]删除字符
# ${var([#%]|##|%%)pattern} * 万用符
for dotfile in "${dotfiles[@]}"; do
if [[ -L ~/${dotfile##*/} ]]; then
echo "删除 ~/${dotfile##*/} 文件"
rm ~/"${dotfile##*/}"
fi
if [[ -L ~/backup/${dotfile##*/} ]]; then
echo "删除 ~/backup/${dotfile##*/} 文件"
rm ~/backup/"${dotfile##*/}"
fi
done
;;
*) echo "没有卸载" ;;
esac
fi
done