diff options
author | Tom Scogland <scogland1@llnl.gov> | 2021-10-28 11:32:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-28 11:32:59 -0700 |
commit | 87e456d59cf43700c8ed257d957794d2c083082a (patch) | |
tree | 1f6b8432029b590c13eac8a84801cd5b7c836ebc /share/spack/spack-completion.bash | |
parent | 5faa457a35a6eb077ab0e246d7ef471c993a4459 (diff) | |
download | spack-87e456d59cf43700c8ed257d957794d2c083082a.tar.gz spack-87e456d59cf43700c8ed257d957794d2c083082a.tar.bz2 spack-87e456d59cf43700c8ed257d957794d2c083082a.tar.xz spack-87e456d59cf43700c8ed257d957794d2c083082a.zip |
spack setup-env.sh: make zsh loading async compatible, and ~10x faster (in some cases) (#26120)
Currently spack is a bit of a bad actor as a zsh plugin, and it was my
fault. The autoload and compinit should really be handled by the user,
as was made abundantly clear when I found spack was doing completion
initialization for *all* of my plugins due to a deferred setup that was
getting messed up by it.
Making this conditional took spack load time from 1.5 seconds (with
module loading disabled) to 0.029 seconds. I can actually afford to load
spack by default with this change in.
Hopefully someday we'll do proper zsh completion support, but for now
this helps a lot.
* use zsh hist expansion in place of dirname
* only run (bash)compinit if compdef/complete missing
* add zsh compiled files to .gitignore
* move changes to .in file, because spack
Diffstat (limited to 'share/spack/spack-completion.bash')
-rwxr-xr-x | share/spack/spack-completion.bash | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash index 72fa08a33a..1c971cb6c4 100755 --- a/share/spack/spack-completion.bash +++ b/share/spack/spack-completion.bash @@ -39,10 +39,14 @@ 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 + if ! typeset -f compdef >& /dev/null ; then + # ensure base completion support is enabled, ignore insecure directories + autoload -U +X compinit && compinit -i + fi + if ! typeset -f complete >& /dev/null ; then + # ensure bash compatible completion support is enabled + autoload -U +X bashcompinit && bashcompinit + fi emulate sh -c "source '$0:A'" return # stop interpreting file fi |