-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall
executable file
·49 lines (42 loc) · 1.11 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
#!/bin/sh
. ./bin/formatting.sh
. ./bin/vars.sh
DOTFILES_DIR="${DOTFILES_DIR:?}"
BACKUP="${BACKUP:-false}"
backup() {
if [ "$BACKUP" = true ]; then
mv "$1" "$1".bk
fi
}
remove_installation() {
info "Removing current config...\n"
for executable_to_install in "$DOTFILES_DIR"/bin/*; do
executable="${HOME:?}/.local/bin/${executable_to_install##*/}"
if [ -L "$executable" ]; then
rm -v "$executable";
elif [ -f "$executable" ]; then
backup "$executable"
rm -v "$executable";
fi
done
for config_to_install in "$DOTFILES_DIR"/config/*; do
config="${XDG_CONFIG_HOME:?}/${config_to_install##*/}"
if [ -L "$config" ]; then
rm -v "$config"
elif [ -e "$config" ]; then
backup "$config"
rm -rv "$config";
fi
done
if [ -L "$HOME"/.bashrc ]; then
rm -v "$HOME"/.bashrc
elif [ -e "$HOME"/.bashrc ]; then
backup "$HOME"/.bashrc
rm -v "$HOME"/.bashrc
fi
}
main() {
remove_installation
info "Finished removing existing config!\n"
}
main