-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall
executable file
·83 lines (72 loc) · 1.33 KB
/
uninstall
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
#!/usr/bin/env bash
# Stop on first error.
set -e
source dot-config/shellcommon/common/common.sh
source dot-config/shellcommon/common/colors.sh
unlink_msg () {
local msg="${RED}Remove${RESET} "
msg+="${BLUE}$1${RESET} "
echo -e "$msg"
}
unlink () {
local _unlink=/usr/bin/unlink
if [ "$SYS_NAME" = "Darwin" ]; then
_unlink=/bin/unlink
fi
local pkg="$1"
if [ -L "$pkg" ]; then
unlink_msg "${pkg/"$HOME"/'~'}"
$_unlink "$pkg"
fi
}
uninstall_home () {
while IFS= read -r pkg;
do
unlink "$pkg"
done < <( \
find "$HOME" -maxdepth 1 \
\( -name "\.*rc" -o -name "\.gitconfig" \
-o -name "\.tmux.conf" \
\) -type l -printf "%p\n" | \
sort
)
}
uninstall_local_bin () {
while IFS= read -r pkg;
do
unlink "$HOME/.local/bin/${pkg##*/}"
done < <( \
find "$PWD/dot-local/bin" -maxdepth 1 -type f -printf "%p\n" \
| sort
)
}
uninstall_config () {
while IFS= read -r pkg;
do
unlink "$pkg"
done < <( \
find "$xdg_config" -maxdepth 1 -type l -printf "%p\n" | \
sort
)
}
unlink_vimrc () {
local vim_home="$HOME/.vim"
while IFS= read -r pkg;
do
unlink "$pkg"
done < <( \
find "$vim_home" -type l -printf "%p\n" | \
sort
)
}
uninstall_sshconfig () {
pkg="$HOME/.ssh/config"
if [ -L "$pkg" ]; then
unlink "$pkg"
fi
}
uninstall_home
uninstall_local_bin
uninstall_config
unlink_vimrc
#uninstall_sshconfig