]> arthur.barton.de Git - ax-zsh.git/blobdiff - bin/axzshctl
00-newline: This plugin is optional for "axzshctl check-plugins"
[ax-zsh.git] / bin / axzshctl
index 4a6fadc21a69101e53a09b81287f61ddd15b6f9b..17cea907be0c8c801523630b1bef2c60508b275d 100755 (executable)
@@ -4,22 +4,21 @@
 # Copyright (c) 2015-2020 Alexander Barton <alex@barton.de>
 #
 
-# Include "ax-common.sh", if available:
-for dir ("$HOME/lib" "$HOME/.ax" /usr/local /opt/ax /usr); do
-       [[ -z "$ax_common_sourced" ]] || break
-       ax_common="${dir}/lib/ax/ax-common.sh"
-       [[ -r "$ax_common" ]] && source "$ax_common"
-done
-if [[ -z "$ax_common_sourced" ]]; then
-       function ax_msg {
-               shift
-               echo "$@"
-       }
-       function ax_error {
-               ax_msg 2 "$@" >&2
-       }
-fi
-unset dir ax_common ax_common_sourced
+# Embedded ax-common compatibility functions ...
+function ax_msg {
+       case "$1" in
+               "0")    c="32"; ;;
+               "1")    c="33"; ;;
+               "2")    c="31"; ;;
+               "-")    c="1";  ;;
+               *)      c="0";  ;;
+       esac
+       shift
+       printf "\e[${c}m%s\e[0m\n" "$@"
+}
+function ax_error {
+       ax_msg 2 "$@" >&2
+}
 
 function Version {
        echo "ax-zsh -- Modular configuration system for the Z shell (ZSH)"
@@ -329,12 +328,15 @@ function CheckPlugins {
                plugin=${dir:t}
 
                # Test if plugin is already enabled
-               [[ -e "$AXZSH/active_plugins/$plugin" ]] \
-                       && enabled=" (enabled)" \
-                       || unset enabled
+               if [[ -e "$AXZSH/active_plugins/$plugin" ]]; then
+                       printf ' \e[1;32m+\e[m "\e[1m%s\e[m" ... ' "${plugin}"
+                       enabled=1
+               else
+                       printf ' \e[1;31m-\e[m "%s" ... ' "${plugin}"
+                       unset enabled
+               fi
 
                # Test plugin ...
-               printf " - \"%s\"%s ... " "$plugin" "$enabled"
                new_plugin=""
                for script ($AXZSH/plugins/$plugin/$plugin.{zshrc,zprofile,ax-io}); do
                        [[ -r "$script" ]] || continue
@@ -354,7 +356,7 @@ function CheckPlugins {
                        ax_msg 1 "optional."
                else
                        [[ -n "$enabled" ]] && invalid_plugins+=($plugin)
-                       ax_msg 2 "failed."
+                       ax_msg 2 "failed ($r)."
                fi
        done
        echo