-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathuninstall.sh
executable file
·42 lines (36 loc) · 1008 Bytes
/
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
#!/usr/bin/env bash
shopt -s dotglob
# get reference to script directory as starting point
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# suppress echos from pushd and popd for clean output
pushd () {
command pushd "$@" > /dev/null
}
popd () {
command popd > /dev/null
}
tryfiles () {
local path="$1"
if [ -d "${DIR}/${path}" ]; then
pushd "${DIR}/${path}" || return
for f in *; do
local newpath="${path}/${f}"
tryfiles "${newpath}"
done
popd || return
if [ -z "$(ls -A "${HOME}/${path}")" ]; then
rmdir "${HOME}/${path}"
printf "Removing empty directory: %s\\n" "${HOME}/${path}"
fi
else
if [ -L "${HOME}/${path}" ]; then
unlink "${HOME}/${path}"
printf "Removing: %s\\n" "${HOME}/${path}"
fi
fi
}
for x in *; do
if [ "$x" != ".git" ] && [ "$x" != "." ] && [ "$x" != ".." ] && [ "$x" != "install.sh" ]&& [ "$x" != "uninstall.sh" ] && [ "$x" != "README.md" ]; then
tryfiles "$x"
fi
done