summaryrefslogtreecommitdiff
path: root/utils/installer/uninstall.sh
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-11-08 18:55:53 +0100
committerGitHub <[email protected]>2021-11-08 18:55:53 +0100
commitee4d580bb2e1dbe7fdb90e8dca5d6296a50eba53 (patch)
treed5596f5443e1d7c4d2dcb876a74d39235c09f5ce /utils/installer/uninstall.sh
parent084e74f86f31796fd4a8144c5d346da01a3992d2 (diff)
fix: update the uninstallation script (#1924)
Diffstat (limited to 'utils/installer/uninstall.sh')
-rwxr-xr-xutils/installer/uninstall.sh69
1 files changed, 58 insertions, 11 deletions
diff --git a/utils/installer/uninstall.sh b/utils/installer/uninstall.sh
index 09923bb1..31007984 100755
--- a/utils/installer/uninstall.sh
+++ b/utils/installer/uninstall.sh
@@ -1,11 +1,58 @@
-#!/bin/sh
-USER_BIN_DIR="$HOME/.local/bin"
-if [ -d "/data/data/com.termux" ]; then
- sudo() {
- eval "$@"
- }
- USER_BIN_DIR="$HOME/../usr/bin"
-fi
-rm -rf ~/.local/share/lunarvim
-sudo rm "$USER_BIN_DIR"/lvim
-rm -rf ~/.local/share/applications/lvim.desktop
+#!/usr/bin/env bash
+set -eo pipefail
+
+ARGS_REMOVE_BACKUPS=0
+
+declare -r XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}"
+declare -r XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}"
+declare -r XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}"
+
+declare -r LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}"
+declare -r LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}"
+
+# TODO: Use a dedicated cache directory #1256
+declare -r LUNARVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim"
+
+LVIM_BIN="$(which lvim 2>/dev/null)"
+
+declare -a __lvim_dirs=(
+ "$LUNARVIM_CONFIG_DIR"
+ "$LUNARVIM_RUNTIME_DIR"
+ "$LUNARVIM_CACHE_DIR"
+)
+
+function usage() {
+ echo "Usage: uninstall.sh [<options>]"
+ echo ""
+ echo "Options:"
+ echo " -h, --help Print this help message"
+ echo " --remove-backups Remove old backup folders as well"
+}
+
+function parse_arguments() {
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ --remove-backups)
+ ARGS_REMOVE_BACKUPS=1
+ ;;
+ -h | --help)
+ usage
+ exit 0
+ ;;
+ esac
+ shift
+ done
+}
+
+function main() {
+ parse_arguments "$@"
+ for dir in "${__lvim_dirs[@]}"; do
+ rm -rf "$dir"
+ if [ "$ARGS_REMOVE_BACKUPS" -eq 1 ]; then
+ rm -rf "$dir.bak"
+ fi
+ done
+ rm -f "$LVIM_BIN"
+}
+
+main "$@"