From: Alexander Barton Date: Sat, 15 Feb 2020 16:34:15 +0000 (+0100) Subject: axzshctl: Handle themes on "disable-plugin" & clean up repositories X-Git-Url: https://arthur.barton.de/gitweb/?p=ax-zsh.git;a=commitdiff_plain;h=49af32139e703544157bafcc95ee166be32e5aee axzshctl: Handle themes on "disable-plugin" & clean up repositories handle plugins providing a theme, and try to remove cloned repositories not only when disabling a plugin succeeded, but always. --- diff --git a/bin/axzshctl b/bin/axzshctl index 1c41425..cd463e3 100755 --- a/bin/axzshctl +++ b/bin/axzshctl @@ -152,14 +152,29 @@ function EnablePlugin { function DisablePlugin { local plugin=$(NormalizedPluginName "$1") local dir="$AXZSH/active_plugins" + local r=-1 - if [[ ! -h "$dir/$plugin" ]]; then - ax_msg 1 "Plugin \"$1\" not active?" - return 1 + # Active theme? + if [[ $(readlink "$AXZSH/active_theme") = "$AXZSH/repos/$plugin/"* ]]; then + rm "$AXZSH/active_theme"; r=$? + fi + + # Active plugin? + if [[ -h "$dir/$plugin" ]]; then + rm "$dir/$plugin"; r=$? + fi + + if [[ $r -eq -1 ]]; then + ax_msg 1 "Plugin \"$1\" not active, nothing to do?" + r=1 + fi + + if [[ "$plugin" = *"#"* ]]; then + # Name matches a cloned repository, try to clean up! + echo "Cleaning up cloned repository ..." + rm -fr "$AXZSH/repos/$plugin" fi - rm -v "$dir/$plugin"; r=$? - [ $r -eq 0 ] && rm -fr "$AXZSH/repos/$plugin" return $r }