]> arthur.barton.de Git - ax-zsh.git/commitdiff
axzshctl: Enhance activation of "foreign" modules
authorAlexander Barton <alex@barton.de>
Sat, 28 Dec 2019 21:59:48 +0000 (22:59 +0100)
committerAlexander Barton <alex@barton.de>
Sat, 28 Dec 2019 21:59:48 +0000 (22:59 +0100)
- Name foreign code "modules", as we don't know yet if it provides a
  theme or a plugin.
- Don't enable it as a plugin when a theme is provided (in this case,
  enable it as a theme only).
- Check for a theme not only on initial cloning, but on all activations.

bin/axzshctl

index 5b6a924e394a3f0d956d24549b532ee3d242e614..1db8a538802763f5ed4a3395b5c63baee939cbf0 100755 (executable)
@@ -107,13 +107,18 @@ function EnablePlugin {
                # GitHub plugin
                mkdir -p "$AXZSH/repos"
                if [[ ! -e "$AXZSH/repos/$plugin" ]]; then
-                       ax_msg - "Cloning plugin from GitHub ..."
+                       ax_msg - "Cloning module 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
+               # Try to enable a theme in this "foreign module", but ignore
+               # errors: we don't know if this module provides a theme or is
+               # a "regular" plugin ...
+               if SetTheme "${plugin#*#}" 2>/dev/null; then
+                       ax_msg 0 "Module \"$1\" was enabled as theme \"${plugin#*#}\"."
+                       # A theme was enabled: So assume that this is a theme
+                       # and don't enable it as plugin.
+                       return 0
                fi
        fi