]> arthur.barton.de Git - ax-zsh.git/blobdiff - bin/axzshctl
New "go" plugin
[ax-zsh.git] / bin / axzshctl
index 64402bf70fed2d3bc03e2a79c83448463ed3c7ab..62121d8b0e0a5b3a160cfb7b1bd35719e1aa92ba 100755 (executable)
@@ -10,7 +10,7 @@ for dir ("$HOME/lib" "$HOME/.ax" /usr/local /opt/ax /usr); do
        ax_common="${dir}/lib/ax/ax-common.sh"
        [[ -r "$ax_common" ]] && source "$ax_common"
 done
-if [[ -z "$ax_common_sourced" ]]; then
+if [[ -z "$ax_common_sourced" || axzsh_is_dumb_terminal ]]; then
        function ax_msg {
                shift
                echo "$@"
@@ -45,6 +45,8 @@ function Usage {
        echo
        echo "  upgrade"
        echo "    Upgrade AX-ZSH installation (requires Git)."
+       echo "  update-caches"
+       echo "    Force rebuild of all cache files."
        echo
        exit 2
 }
@@ -108,6 +110,10 @@ function EnablePlugin {
                        ax_msg - "Cloning plugin from GitHub ..."
                        git clone "https://github.com/$1.git" \
                         "$AXZSH/repos/$plugin"
+                       # Try to enable a theme in this "foreign" plugin, but
+                       # ignore errors: we don't know if this plugin provides
+                       # a theme at all ...
+                       SetTheme "${plugin#*#}" 2>/dev/null
                fi
        fi
 
@@ -204,8 +210,23 @@ function SetTheme {
        elif [ -r "$AXZSH/themes/$1.axzshtheme" ]; then
                theme="$AXZSH/themes/$1.axzshtheme"
        else
-               echo "Theme \"$1\" not found!"
-               return 1
+               # Look for theme inside of installed plugins:
+               for dname (
+                       "$AXZSH/custom_plugins/"*(N)
+                       "$AXZSH/repos/"*(N)
+               ); do
+                       if [[ -r "$dname/$1.axzshtheme" ]]; then
+                               theme="$dname/$1.axzshtheme"
+                               break
+                       elif [[ -r "$dname/$1.zsh-theme" ]]; then
+                               theme="$dname/$1.zsh-theme"
+                               break
+                       fi
+               done
+               if [[ -z "$theme" ]]; then
+                       echo "Theme \"$1\" not found!"
+                       return 1
+               fi
        fi
        ln -sv "$theme" "$link_name" || return 1
        return $?
@@ -356,8 +377,7 @@ case "$cmd" in
                ;;
        "enable-default-plugins")
                [[ $# -eq 0 ]] || Usage
-               EnableDefaultPlugins
-               UpdatePluginCache
+               EnableDefaultPlugins && UpdatePluginCache
                ;;
        "check-plugins")
                [[ $# -eq 0 ]] || Usage
@@ -365,8 +385,7 @@ case "$cmd" in
                ;;
        "set-theme")
                [[ $# -eq 1 ]] || Usage
-               SetTheme "$1"
-               UpdatePluginCache
+               SetTheme "$1" && UpdatePluginCache
                ;;
        "upgrade")
                [[ $# -eq 0 ]] || Usage
@@ -374,6 +393,10 @@ case "$cmd" in
                UpgradeForeignPlugins
                UpdatePluginCache
                ;;
+       "update-caches")
+               [[ $# -eq 0 ]] || Usage
+               UpdatePluginCache
+               ;;
        *)
                Usage
 esac