summaryrefslogtreecommitdiff
path: root/share/spack/spack-completion.bash
diff options
context:
space:
mode:
Diffstat (limited to 'share/spack/spack-completion.bash')
-rwxr-xr-xshare/spack/spack-completion.bash15
1 files changed, 14 insertions, 1 deletions
diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash
index 1761fcb60d..0143d305ca 100755
--- a/share/spack/spack-completion.bash
+++ b/share/spack/spack-completion.bash
@@ -37,6 +37,17 @@
#
# See `man bash` for more details.
+if test -n "${ZSH_VERSION:-}" ; then
+ if [[ "$(emulate)" = zsh ]] ; then
+ # ensure base completion support is enabled, ignore insecure directories
+ autoload -U +X compinit && compinit -i
+ # ensure bash compatible completion support is enabled
+ autoload -U +X bashcompinit && bashcompinit
+ emulate sh -c "source '$0:A'"
+ return # stop interpreting file
+ fi
+fi
+
# Bash programmable completion for Spack
_bash_completion_spack() {
# In all following examples, let the cursor be denoted by brackets, i.e. []
@@ -117,7 +128,9 @@ _bash_completion_spack() {
#_test_vars >> temp
# Make sure function exists before calling it
- if [[ "$(type -t $subfunction)" == "function" ]]
+ local rgx #this dance is necessary to cover bash and zsh regex
+ rgx="$subfunction.*function.* "
+ if [[ "$(type $subfunction 2>&1)" =~ $rgx ]]
then
$subfunction
COMPREPLY=($(compgen -W "$SPACK_COMPREPLY" -- "$cur"))