]> arthur.barton.de Git - ax-zsh.git/commitdiff
Add axzshctl subcommands "enable" and "disable"
authorAlexander Barton <alex@barton.de>
Fri, 21 Oct 2016 12:37:25 +0000 (14:37 +0200)
committerAlexander Barton <alex@barton.de>
Fri, 21 Oct 2016 12:37:25 +0000 (14:37 +0200)
bin/axzshctl
core/50_axzsh/functions/_axzsh

index b9d20d36a17fde3001c7097f3ea9ccee73b594e1..d2216bbe566d01df133d5376f8df7a3d220abafa 100755 (executable)
@@ -21,6 +21,12 @@ unset dir ax_common ax_common_sourced
 function Usage {
        echo "Usage: $NAME <command> [...]"
        echo
+       echo "  enable"
+       echo "    Enable AX-ZSH altogether."
+       echo
+       echo "  disable"
+       echo "    Disable AX-ZSH altogether."
+       echo
        echo "  enable-plugin <name|directory> [<name|directory> [...]]"
        echo "    Enable plugin(s)."
        echo
@@ -55,6 +61,25 @@ function NormalizedPluginName {
        fi
 }
 
+function EnableAXZSH {
+       for f (~/.zlogin ~/.zlogout ~/.zprofile ~/.zshrc); do
+               ln -sv "$AXZSH/ax.zsh" "$f" \
+                       || ax_msg 2 "Failed to create symbolic link for \"$f\"!"
+       done
+}
+
+function DisableAXZSH {
+       for f (~/.zlogin ~/.zlogout ~/.zprofile ~/.zshrc); do
+               if [ -h "$f" ]; then
+                       rm -v "$f" || ax_msg 2 "Failed to remove \"$f\"!"
+               elif [ -e "$f" ]; then
+                       ax_msg 2 "Error: Not removing \"$f\", it is not a symbolic link!"
+               else
+                       ax_msg 1 "Warning: \"$f\" already does not exist. Ok."
+               fi
+       done
+}
+
 function EnablePlugin {
        local plugin=$(NormalizedPluginName "$1")
        local dir="$AXZSH/active_plugins"
@@ -278,6 +303,14 @@ cmd="$1"
 shift
 
 case "$cmd" in
+       "enable")
+               [[ $# -eq 0 ]] || Usage
+               EnableAXZSH
+               ;;
+       "disable")
+               [[ $# -eq 0 ]] || Usage
+               DisableAXZSH
+               ;;
        "enable-plugin")
                [[ $# -gt 0 ]] || Usage
                for plugin in "$@"; do
index bee7353be6fd640a7dcb1f1080f877a8b155a1f5..014221406f8d4da655e5fd448a7f1b3694dcff19 100644 (file)
@@ -3,6 +3,8 @@
 _axzshctl() {
        _arguments \
                '1: :((
+                       enable\:"Enable AX-ZSH."
+                       disable\:"Disable AX-ZSH."
                        enable-plugin\:"Enable plugin(s)."
                        disable-plugin\:"Disable plugin(s)."
                        reset-plugins\:"Reset active plugins to the default set."