-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·59 lines (43 loc) · 1.24 KB
/
uninstall.sh
File metadata and controls
executable file
·59 lines (43 loc) · 1.24 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
#!/usr/bin/env bash
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
unsetup_inputrc() {
local dotfiles_inputrc="${script_dir}/inputrc"
# if the installed inputrc is not linked to the one from those dotfiles
# then do not remove it
if [[ ! -L "$HOME/.inputrc" || ! -e "$HOME/.inputrc" ]] || ! diff -q "$HOME/.inputrc" "${dotfiles_inputrc}"; then
return 0
fi
rm "$HOME/.inputrc"
local bak_inputrc
bak_inputrc="$(printf '%s\n' "$HOME/.inputrc.bak."* | sort -r | head -n 1)"
if [[ -z "$bak_inputrc" || ! -f "$bak_inputrc" ]]; then
return 0
fi
mv "$bak_inputrc" "$HOME/.inputrc"
}
unsetup_bashrc() {
sed -i '/Fruchix\/dotfiles:install.sh/d' "$HOME/.bashrc"
# remove bashrc if empty
if [[ -z "$(cat "$HOME/.bashrc")" ]]; then
rm "$HOME/.bashrc"
fi
}
unsetup_zshrc() {
sed -i '/Fruchix\/dotfiles:install.sh/d' "$HOME/.zshrc"
# remove zshrc if empty
if [[ -z "$(cat "$HOME/.zshrc")" ]]; then
rm "$HOME/.zshrc"
fi
}
unsetup_siu() {
if [[ ! -d "$HOME/.siu" ]]; then
return 0
fi
if ! ./"$HOME"/.siu/uninstall; then
rm -rf "$HOME/.siu"
fi
}
unsetup_inputrc
unsetup_bashrc
unsetup_zshrc
unsetup_siu