]> arthur.barton.de Git - ax-zsh.git/blobdiff - bin/axzshctl
axzshctl check-plugins: Enhance output
[ax-zsh.git] / bin / axzshctl
index efc8a982f3d939f00ef8c13dc632c9067728046a..34d198ec9153f33dc42ab70c72f279fadc229ff1 100755 (executable)
@@ -21,6 +21,19 @@ if [[ -z "$ax_common_sourced" ]]; then
 fi
 unset dir ax_common ax_common_sourced
 
+function Version {
+       echo "ax-zsh -- Modular configuration system for the Z shell (ZSH)"
+       echo "Copyright (c) 2015-2019 Alexander Barton <alex@barton.de>."
+       echo "Licensed under the terms of the MIT license, see LICENSE.md for details."
+       echo "Homepage: <https://github.com/alexbarton/ax-zsh>"
+       if [[ -d "$AXZSH/.git" && -n "$commands[git]" ]]; then
+               echo -n "Version: Git ID "
+               ( cd "$AXZSH" && git describe --always )
+       fi
+       echo
+       exit 0
+}
+
 function Usage {
        echo "Usage: $NAME <command> [...]"
        echo
@@ -59,13 +72,14 @@ function UpdatePluginCache {
 
        [[ "$1" = "-v" ]] && ax_msg - "Updating plugin cache ..."
        rm -rf \
+               $AXZSH/cache/ax-io.cache \
                $AXZSH/cache/zlogin.cache \
                $AXZSH/cache/zlogout.cache \
                $AXZSH/cache/zprofile.cache \
                $AXZSH/cache/zshrc.cache \
                || return 1
        echo "Regenerating cache files ..."
-       zsh -ilc '' >/dev/null
+       AXZSH_PLUGIN_CHECK=1 zsh -ilc '' >/dev/null
 }
 
 function NormalizedPluginName {
@@ -220,6 +234,10 @@ function EnableDefaultPlugins {
 function SetTheme {
        local link_name="$AXZSH/active_theme"
 
+       # --- Powerlevel10k ---
+       # Remove "instant prompt" configuration, if any ...
+       rm -f "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
+
        if [[ "$1" = "-" ]]; then
                rm -f "$link_name" || return 1
                ax_msg 0 "Theme settings have been reset."
@@ -307,24 +325,27 @@ function CheckPlugins {
        invalid_plugins=()
 
        ax_msg - "Checking plugins ..."
-       for dir ($AXZSH/plugins/*(N)); do
+       for dir ($AXZSH/plugins/[a-z0-9]*(N)); do
                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}); do
+               for script ($AXZSH/plugins/$plugin/$plugin.{zshrc,zprofile,ax-io}); do
                        [[ -r "$script" ]] || continue
                        AXZSH_PLUGIN_CHECK=1 zsh -i -c "source $script"; r=$?
                        if [[ $r -eq 0 ]]; then
                                new_plugin=$plugin
-                               break
                        fi
+                       break
                done
                if [[ -n "$new_plugin" ]]; then
                        detected_plugins+=($new_plugin)
@@ -336,7 +357,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
@@ -433,8 +454,11 @@ case "$cmd" in
                [[ $# -eq 0 ]] || Usage
                UpdatePluginCache -v
                ;;
-       "--help")
-               Usage
+       "--version"|"version")
+               Version >&2
+               ;;
+       "--help"|"help")
+               Usage >&2
                ;;
        *)
                ax_error "Invalid command \"$cmd\"!"