]> arthur.barton.de Git - ax-zsh.git/commitdiff
axzshctl: Enhance completions, include cloned modules
authorAlexander Barton <alex@barton.de>
Sat, 28 Dec 2019 22:40:41 +0000 (23:40 +0100)
committerAlexander Barton <alex@barton.de>
Sat, 28 Dec 2019 22:40:41 +0000 (23:40 +0100)
Use ZSH globbing instead of calling external commands (like ls, cut and
find), and include cloned repositories ("foreign modules") in the
completions, too.

core/50_axzsh/functions/_axzsh

index bd83bfa8b8a89175a4137340b899a953d1c38de2..3c3d0c56260d795c5b4488ea64ede758843b0820 100644 (file)
@@ -22,14 +22,15 @@ _axzshctl() {
                case "$words[2]" in
                  "enable-plugin"|"disable-plugin")
                        compadd "$@" -- \
-                               $(ls -1 "$AXZSH"/plugins) \
-                               $(ls -1 "$AXZSH"/custom_plugins)
+                               "$AXZSH"/plugins/*(/:t) \
+                               "$AXZSH"/custom_plugins/*(N/:t) \
+                               "$AXZSH"/repos/*(/:t:s/#/\\/)
                        ;;
                  "set-theme")
                        compadd "$@" -- "-" \
-                               $(ls -1 "$AXZSH"/themes | cut -d'.' -f1) \
-                               $(ls -1 "$AXZSH"/custom_themes | cut -d'.' -f1) \
-                               $(find "$AXZSH/custom_plugins" "$AXZSH/repos" -maxdepth 2 -iname '*.zsh-theme' -exec basename {} \; | cut -d'.' -f1)
+                               "$AXZSH"/themes/*.axzshtheme(:r:t) \
+                               "$AXZSH"/custom_themes/*.axzshtheme(N:r:t) \
+                               "$AXZSH"/repos/*/*.zsh-theme(N:r:t)
                        ;;
                esac
                ;;