marlonrichert / zsh-snap

⚡️ Znap! Fast, easy-to-use tools for Zsh dotfiles & plugins, plus git repos
MIT License
1.34k stars 40 forks source link

`znap` tab-completion works only once on macOS #128

Closed thk-gh closed 2 years ago

thk-gh commented 3 years ago

Hi,

I have a weird problem with znap on my MacBook (running macOS 11.6).

Tab-completion of znap itself is working only once after installation or after changes to .zshrc -- in following shells or after 'znap restart' tab-completion is not working anymore. I do not have this behaviour on other machines running (Void) Linux or OpenBSD.

I can't figure out what is causing this -- maybe you consider this a bug and can fix it?

Here's a demonstration so you see what I'm talking about:

(click to expand) ``` ❯ znap [TAB] clean -- remove outdated .zwc binaries clone -- download repos in parallel compdef -- add output of command as completion function (deprecated) compile -- compile zsh scripts and functions eval -- cache & eval output of command fpath -- install command output as a function function -- create a set of lazy-loading functions help -- print help text for command ignore -- add local exclude patterns to repo install -- install executables & completion functions multi -- run tasks in parallel prompt -- instant prompt from repo pull -- update repos in parallel restart -- validate dotfiles & safely restart Zsh source -- load plugins status -- fetch updates & show git status uninstall -- remove executables & completion functions ~ ❯ znap restart Validating dotfiles... Restarting Zsh... ~ ❯ znap [TAB] Applications/ Library/ Public/ src/ Applications\ \(Parallels\)/ Movies/ bin/ tmp/ Desktop/ Music/ fossil/ Documents/ Parallels/ lib/ Downloads/ Pictures/ org/ ~ ❯ zsh --version zsh 5.8 (x86_64-apple-darwin20.0) ```

FWIW, here's most of my .zshrc (I left out key bindings and aliases):

(click to expand) ``` [[ ! -o interactive ]] && return # Znap: # Download Znap, if it's not there yet. [[ -f ~/src/zsh/zsh-snap/znap.zsh ]] || git clone --depth 1 -- \ https://github.com/marlonrichert/zsh-snap.git ~/src/zsh/zsh-snap # source ~/src/zsh/zsh-snap/znap.zsh # Start Znap #zstyle ':znap:*' auto-compile no # # https://github.com/sindresorhus/pure : # change the path color #zstyle :prompt:pure:path color white znap prompt sindresorhus/pure # # `znap source` automatically downloads and starts your plugins. #znap source marlonrichert/zsh-autocomplete #znap source zsh-users/zsh-autosuggestions # https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md : ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor) znap source zsh-users/zsh-syntax-highlighting # Miscellanous options: setopt extendedglob nomatch notify # autocd ? setopt CORRECT_ALL # Correct spelling of all arguments in the command line #REPORTTIME=3 # Report command running time if it is more than 3 seconds # Autocompletion: #autoload -Uz compinit && compinit -u zstyle :compinstall filename '~/.zshrc' zstyle ':completion:*' completer _complete _correct _approximate zstyle ':completion:*' menu select zstyle ':completion:*' use-cache on zstyle ':completion:*' cache-path ~/.zsh_cache # doesn't work? zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS' zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS' zstyle ':completion:*:functions' ignored-patterns '_*' setopt COMPLETE_ALIASES # History: HISTFILE=~/.zsh_history HISTSIZE=5000 SAVEHIST=4000 setopt SHARE_HISTORY setopt HIST_IGNORE_ALL_DUPS # Do not keep duplicate commands in history setopt HIST_IGNORE_SPACE # Do not remember commands that start with a whitespace. #setopt HIST_FIND_NO_DUPS # Do not display a previously found event. setopt HIST_VERIFY # Do not execute immediately upon history expansion. setopt HIST_NO_STORE # Don't store history commands setopt INC_APPEND_HISTORY # Add commands to history as they are entered unsetopt EXTENDED_HISTORY INC_APPEND_HISTORY_TIME ```

Thanks for your time, and thanks for writing and sharing zsh-snap! -- Thomas

marlonrichert commented 3 years ago

Sorry, but I'm unable to reproduce this. I created a temp folder, pasted your .zshrc file into it and then did this:

env -i HOME=$PWD ZDOTDIR=$PWD TERM=$TERM PATH=$PATH FPATH=$FPATH zsh -d

Works fine, which makes me suspect there might be something in your environment variables that's messing things up.

Can you run env and paste the output here?

thk-gh commented 3 years ago

Yes, sure:

(click to expand) ``` ❯ env TMPDIR=/var/folders/m4/kzzn11h17djb62bwk1t27_vc0000gn/T/ __CFBundleIdentifier=com.apple.Terminal XPC_FLAGS=0x0 TERM=xterm-256color DISPLAY=/private/tmp/com.apple.launchd.BrwRow734J/org.xquartz:0 SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.T0zmJlp35i/Listeners XPC_SERVICE_NAME=0 TERM_PROGRAM=Apple_Terminal TERM_PROGRAM_VERSION=440 TERM_SESSION_ID=06818675-EC30-476C-8EC3-951CA522CD38 SHELL=/bin/zsh HOME=/Users/thk LOGNAME=thk USER=thk PATH=/Users/thk/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Users/thk/.opam/4.12.0/bin:/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/Users/thk/bin:/Users/thk/src/go/bin SHLVL=1 PWD=/Users/thk OLDPWD=/Users/thk PAGER=less EDITOR=emacs GOPATH=/Users/thk/src/go DUB_COMPILERS_PATH=/usr/local/opt/dmd/bin OPAMNOENVNOTICE=true OPAM_SWITCH_PREFIX=/Users/thk/.opam/4.12.0 CAML_LD_LIBRARY_PATH=/Users/thk/.opam/4.12.0/lib/stublibs:/Users/thk/.opam/4.12.0/lib/ocaml/stublibs:/Users/thk/.opam/4.12.0/lib/ocaml OCAML_TOPLEVEL_PATH=/Users/thk/.opam/4.12.0/lib/toplevel XDG_CACHE_HOME=/Users/thk/.cache XDG_CONFIG_HOME=/Users/thk/.config XDG_DATA_HOME=/Users/thk/.local/share PROMPT_EOL_MARK= CONDA_CHANGEPS1=no LANG=en_US.UTF-8 VIRTUAL_ENV_DISABLE_PROMPT=12 _=/usr/bin/env ```

Thanks again for looking into this!

marlonrichert commented 3 years ago

I don't see anything suspicious in there.

After trying completion on znap, can you do functions -T _znap, then try completion again and paste the output here?

thk-gh commented 3 years ago
❯ znap [TAB]
Applications/                 Library/                      Public/       [...]                 

~
❯ functions -T _znap

~
❯ echo $?
1

~
❯ znap [TAB]
Applications/                 Library/                      Public/       [...]

In a shell/terminal where tab-completion works, it is:

~
❯ functions -T _znap

~
❯ echo $?
0

This is not really a grave problem, since it affects apparently only Znap's own completions (brew [TAB] e.g. works as expected), but...

thk-gh commented 3 years ago

I just noticed that there should be some debugging output...

This is from a shell/terminal where tab-completions works. I could not get such info from a shell where it does not, sorry.

~
❯ functions -T _znap

~
❯ znap ++++++ _znap:3 @_znap:3> [[ -v _ZNAP_ARGS ]]
++++++ _znap:6 @_znap:6> local -a subcommands=( )
++++++ _znap:7 @_znap:7> local k
++++++ _znap:7 @_znap:7> k=clean
++++++ _znap:8 @_znap:8> subcommands+=( 'clean\:'\''remove outdated .zwc binaries'\' ) 
++++++ _znap:7 @_znap:7> k=clone
++++++ _znap:8 @_znap:8> subcommands+=( 'clone\:'\''download repos in parallel'\' ) 
++++++ _znap:7 @_znap:7> k=compdef
++++++ _znap:8 @_znap:8> subcommands+=( 'compdef\:'\''add output of command as completion function (deprecated)'\' ) 
++++++ _znap:7 @_znap:7> k=compile
++++++ _znap:8 @_znap:8> subcommands+=( 'compile\:'\''compile zsh scripts and functions'\' ) 
++++++ _znap:7 @_znap:7> k=eval
++++++ _znap:8 @_znap:8> subcommands+=( 'eval\:'\''cache & eval output of command'\' ) 
++++++ _znap:7 @_znap:7> k=fpath
++++++ _znap:8 @_znap:8> subcommands+=( 'fpath\:'\''install command output as a function'\' ) 
++++++ _znap:7 @_znap:7> k=function
++++++ _znap:8 @_znap:8> subcommands+=( 'function\:'\''create a set of lazy-loading functions'\' ) 
++++++ _znap:7 @_znap:7> k=help
++++++ _znap:8 @_znap:8> subcommands+=( 'help\:'\''print help text for command'\' ) 
++++++ _znap:7 @_znap:7> k=ignore
++++++ _znap:8 @_znap:8> subcommands+=( 'ignore\:'\''add local exclude patterns to repo'\' ) 
++++++ _znap:7 @_znap:7> k=install
++++++ _znap:8 @_znap:8> subcommands+=( 'install\:'\''install executables & completion functions'\' ) 
++++++ _znap:7 @_znap:7> k=multi
++++++ _znap:8 @_znap:8> subcommands+=( 'multi\:'\''run tasks in parallel'\' ) 
++++++ _znap:7 @_znap:7> k=prompt
++++++ _znap:8 @_znap:8> subcommands+=( 'prompt\:'\''instant prompt from repo'\' ) 
++++++ _znap:7 @_znap:7> k=pull
++++++ _znap:8 @_znap:8> subcommands+=( 'pull\:'\''update repos in parallel'\' ) 
++++++ _znap:7 @_znap:7> k=restart
++++++ _znap:8 @_znap:8> subcommands+=( 'restart\:'\''validate dotfiles & safely restart Zsh'\' ) 
++++++ _znap:7 @_znap:7> k=source
++++++ _znap:8 @_znap:8> subcommands+=( 'source\:'\''load plugins'\' ) 
++++++ _znap:7 @_znap:7> k=status
++++++ _znap:8 @_znap:8> subcommands+=( 'status\:'\''fetch updates & show git status'\' ) 
++++++ _znap:7 @_znap:7> k=uninstall
++++++ _znap:8 @_znap:8> subcommands+=( 'uninstall\:'\''remove executables & completion functions'\' ) 
++++++ _znap:11 @_znap:11> local -A opt_args
++++++ _znap:12 @_znap:12> local -a opts=( -qS ' ' ) context line state state_descr
++++++ _znap:13 @_znap:13> _arguments -A '' -O opts : ':command:(( clean\:'\''remove outdated .zwc binaries'\'' clone\:'\''download repos in parallel'\'' compdef\:'\''add output of command as completion function (deprecated)'\'' compile\:'\''compile zsh scripts and functions'\'' eval\:'\''cache & eval output of command'\'' fpath\:'\''install command output as a function'\'' function\:'\''create a set of lazy-loading functions'\'' help\:'\''print help text for command'\'' ignore\:'\''add local exclude patterns to repo'\'' install\:'\''install executables & completion functions'\'' multi\:'\''run tasks in parallel'\'' prompt\:'\''instant prompt from repo'\'' pull\:'\''update repos in parallel'\'' restart\:'\''validate dotfiles & safely restart Zsh'\'' source\:'\''load plugins'\'' status\:'\''fetch updates & show git status'\'' uninstall\:'\''remove executables & completion functions'\'' ))' '*:: :->next'
++++++ _znap:14 @_znap:14> local ret=0
++++++ _znap:16 @_znap:16> [[ '' == next ]]
++++++ _znap:17 @_znap:17> return ret
  znap
clean      -- remove outdated .zwc binaries
clone      -- download repos in parallel
compdef    -- add output of command as completion function (deprecated)
compile    -- compile zsh scripts and functions
eval       -- cache & eval output of command
fpath      -- install command output as a function
function   -- create a set of lazy-loading functions
help       -- print help text for command
ignore     -- add local exclude patterns to repo
install    -- install executables & completion functions
multi      -- run tasks in parallel
prompt     -- instant prompt from repo
pull       -- update repos in parallel
restart    -- validate dotfiles & safely restart Zsh
source     -- load plugins
status     -- fetch updates & show git status
uninstall  -- remove executables & completion functions
marlonrichert commented 3 years ago

I could not get such info from a shell where it does not, sorry.

In the shell where it does not work, what output do you get from trying completion after running functions -t _main_complete? And what output do you get from print $_comps[znap]?

thk-gh commented 3 years ago
(click to expand) ``` ~ ❯ print $_comps[znap] ~ ❯ functions -t _main_complete ~ ❯ znap +++ _main_complete:11 @_main_complete:11> local IFS=$' \t\n\C-@' +++ _main_complete:25 @_main_complete:25> eval $'local -A _comp_caller_options;\n _comp_caller_options=(${(kv)options[@]});\n setopt localoptions localtraps localpatterns ${_comp_options[@]};\n local IFS=$\' \\t\\r\\n\\0\';\n builtin enable -p \\| \\~ \\( \\? \\* \\[ \\< \\^ \\# 2>&-;\n exec local -A _comp_caller_options ++++ _main_complete:27 @(eval):1> _comp_caller_options=( posixargzero off autolist on printexitvalue off kshzerosubscript off histreduceblanks off chaselinks off extendedglob on localloops off histnostore on automenu on globcomplete off unset on listpacked off promptsubst on shwordsplit off pathdirs off kshtypeset off listtypes on warncreateglobal off promptbang off dotglob off braceexpand on listbeep on correctall on privileged off numericglobsort off histverify on trackall on histsubstpattern off globstarshort off cbases off rcquotes off posixaliases off histfindnodups off bashautolist off sharehistory on overstrike off kshautoload off incappendhistory on appendcreate off promptcr off mailwarn off pushdignoredups off interactive on ignoreeof off globsubst off rematchpcre off monitor on histsavebycopy on histbeep on debugbeforecmd on magicequalsubst off rmstarsilent off posixjobs off hashcmds on posixtraps off extendedhistory off notify on kshoptionprint off histexpiredupsfirst off glob on posixcd off braceccl off badpattern on longlistjobs off banghist on dvorak off alwaystoend off hashall on warnnestedvar off globalexport on ksharrays off correct off cdsilent off autonamedirs off histexpand on typesetsilent off rmstarwait off histnofunctions off autoparamslash on trapsasync off sunkeyboardhack off promptsp on histsavenodups off autocd off allexport off posixidentifiers off cshjunkiehistory off autopushd off completeinword off completealiases on aliases on autocontinue off appendhistory on aliasfuncdef off singlelinezle off hashlistall on ignoreclosebraces off recexact off localoptions off interactivecomments off errexit off cshjunkiequotes off markdirs off hashdirs on cdablevars off rcexpandparam off vi off printeightbit off multifuncdef on xtrace on login on cshjunkieloops off histappend on histignorespace on evallineno on shfileexpansion off rcs on functionargzero on errreturn off combiningchars on histignoredups off histfcntllock off beep off autoremoveslash on hup on globdots off checkrunningjobs on autoparamkeys on shnullcmd off multibyte on zle on promptpercent on flowcontrol on continueonerror off incappendhistorytime off autoresume off globassign off caseglob on shortloops on bsdecho off cprecedences off log on transientrprompt off verbose off localpatterns off ignorebraces off pipefail off equals on menucomplete off cshnullglob off casematch on promptvars on histallowclobber off bareglobqual on shinstdin on restricted off pushdminus off nullglob off chasedots off mailwarning off listambiguous on cshnullcmd off bashrematch off octalzeroes off forcefloat off exec on multios on emacs off nomatch on pathscript off localtraps off stdin on onecmd off kshglob off clobber on posixbuiltins off alwayslastprompt on pushdtohome off histignorealldups on hashexecutablesonly off pushdsilent off shoptionletters off physical off sourcetrace off histlexwords off bgnice on globalrcs on posixstrings off checkjobs on shglob off singlecommand off listrowsfirst off ) ++++ _main_complete:28 @(eval):2> setopt localoptions localtraps localpatterns bareglobqual extendedglob glob multibyte multifuncdef nullglob rcexpandparam unset NO_allexport NO_aliases NO_cshnullglob NO_cshjunkiequotes NO_errexit NO_errreturn NO_globassign NO_globsubst NO_histsubstpattern NO_ignorebraces NO_ignoreclosebraces NO_kshglob NO_ksharrays NO_kshtypeset NO_markdirs NO_octalzeroes NO_posixbuiltins NO_posixidentifiers NO_shwordsplit NO_shglob NO_warnnestedvar NO_warncreateglobal ++++ _main_complete:29 @(eval):3> local IFS=$' \t\C-M\n\C-@' ++++ _main_complete:30 @(eval):4> enable -p '|' '~' '(' '?' '*' '[' '<' '^' '#' ++++ _main_complete:32 @(eval):6> trap - ZERR ++++ _main_complete:33 @(eval):7> local -a reply ++++ _main_complete:34 @(eval):8> local REPLY ++++ _main_complete:35 @(eval):9> local REPORTTIME ++++ _main_complete:36 @(eval):10> unset REPORTTIME +++ _main_complete:27 @_main_complete:27> local func funcs ret=1 tmp _compskip format nm call match min max i num _completers _completer _completer_num curtag _comp_force_list _matchers _matcher _c_matcher _matcher_num _comp_tags _comp_mesg mesg str context state state_descr line opt_args val_args curcontext='' _last_nmatches=-1 _last_menu_style _def_menu_style _menu_style sel _tags_level=0 _saved_exact='' _saved_lastprompt=yes _saved_list=ambiguous _saved_insert=automenu-unambiguous _saved_colors='' _saved_colors_set=0 _ambiguous_color='' +++ _main_complete:42 @_main_complete:42> local _comp_priv_prefix +++ _main_complete:43 @_main_complete:43> unset _comp_priv_prefix +++ _main_complete:46 @_main_complete:46> local -a precommands +++ _main_complete:52 @_main_complete:52> local -ar builtin_precommands=( - builtin eval exec nocorrect noglob time ) +++ _main_complete:54 @_main_complete:54> typeset -U _lastdescr _comp_ignore _comp_colors +++ _main_complete:58 @_main_complete:58> [[ -z '' ]] +++ _main_complete:58 @_main_complete:58> curcontext=::: +++ _main_complete:60 @_main_complete:60> zstyle -s :completion::::: insert-tab tmp +++ _main_complete:60 @_main_complete:60> tmp=yes +++ _main_complete:62 @_main_complete:62> [[ yes = *pending(|[[:blank:]]*) || yes = *pending=(#b)([0-9]##)(|[[:blank:]]*) ]] +++ _main_complete:70 @_main_complete:70> [[ automenu-unambiguous = tab* ]] +++ _main_complete:83 @_main_complete:83> [[ '' = \* ]] +++ _main_complete:93 @_main_complete:93> [[ -z '' ]] +++ _main_complete:94 @_main_complete:94> [[ -o equals ]] +++ _main_complete:94 @_main_complete:94> compset -P 1 '=' +++ _main_complete:96 @_main_complete:96> [[ '' != */* && '' = \~ ]] +++ _main_complete:104 @_main_complete:104> _setup default ++++ _setup:3 @_setup:3> local val nm=0 ++++ _setup:5 @_setup:5> [[ 1 -eq 1 ]] ++++ _setup:5 @_setup:5> 2=default ++++ _setup:7 @_setup:7> zstyle -a :completion:::::default list-colors val ++++ _setup:21 @_setup:21> [[ default = default ]] ++++ _setup:22 @_setup:22> unset ZLS_COLORS ZLS_COLOURS ++++ _setup:27 @_setup:27> zstyle -s :completion:::::default show-ambiguity val ++++ _setup:32 @_setup:32> zstyle -t :completion:::::default list-packed ++++ _setup:34 @_setup:34> [[ 2 -eq 1 ]] ++++ _setup:37 @_setup:37> compstate[list]=ambiguous ++++ _setup:40 @_setup:40> zstyle -t :completion:::::default list-rows-first ++++ _setup:42 @_setup:42> [[ 2 -eq 1 ]] ++++ _setup:45 @_setup:45> compstate[list]=ambiguous ++++ _setup:48 @_setup:48> zstyle -t :completion:::::default last-prompt ++++ _setup:50 @_setup:50> [[ 2 -eq 1 ]] ++++ _setup:53 @_setup:53> compstate[last_prompt]=yes ++++ _setup:56 @_setup:56> zstyle -t :completion:::::default accept-exact ++++ _setup:58 @_setup:58> [[ 2 -eq 1 ]] ++++ _setup:61 @_setup:61> compstate[exact]='' ++++ _setup:64 @_setup:64> [[ _last_nmatches -ge 0 ]] ++++ _setup:67 @_setup:67> zstyle -a :completion:::::default menu val ++++ _setup:68 @_setup:68> _last_nmatches=0 ++++ _setup:69 @_setup:69> _last_menu_style=( select ) ++++ _setup:74 @_setup:74> [[ '' != always ]] ++++ _setup:75 @_setup:75> zstyle -s :completion:::::default force-list val +++ _main_complete:105 @_main_complete:105> _def_menu_style=( select ) +++ _main_complete:114 @_main_complete:114> _last_menu_style=( ) +++ _main_complete:116 @_main_complete:116> zstyle -s :completion:::::default list-prompt tmp +++ _main_complete:120 @_main_complete:120> zstyle -s :completion:::::default select-prompt tmp +++ _main_complete:124 @_main_complete:124> zstyle -s :completion:::::default select-scroll tmp +++ _main_complete:131 @_main_complete:131> (( 0 )) +++ _main_complete:143 @_main_complete:143> zstyle -a :completion::::: completer _completers +++ _main_complete:149 @_main_complete:149> _completer_num=1 +++ _main_complete:152 @_main_complete:152> integer SECONDS=0 +++ _main_complete:166 @_main_complete:166> funcs=( ) +++ _main_complete:167 @_main_complete:167> compprefuncs=( ) +++ _main_complete:172 @_main_complete:172> tmp=_complete +++ _main_complete:174 @_main_complete:174> [[ -n '' ]] +++ _main_complete:176 @_main_complete:176> [[ _complete = *:-* ]] +++ _main_complete:179 @_main_complete:179> [[ _complete = *:* ]] +++ _main_complete:183 @_main_complete:183> _completer=complete +++ _main_complete:186 @_main_complete:186> curcontext=:complete:: +++ _main_complete:187 @_main_complete:187> zstyle -t :completion::complete::: show-completer +++ _main_complete:190 @_main_complete:190> zstyle -a :completion::complete::: matcher-list _matchers +++ _main_complete:191 @_main_complete:191> _matchers=( '' ) +++ _main_complete:193 @_main_complete:193> _matcher_num=1 +++ _main_complete:194 @_main_complete:194> _matcher='' +++ _main_complete:195 @_main_complete:195> _c_matcher= +++ _main_complete:196 @_main_complete:196> [[ '' == +* ]] +++ _main_complete:199 @_main_complete:199> _matcher='' +++ _main_complete:202 @_main_complete:202> _comp_mesg='' +++ _main_complete:203 @_main_complete:203> [[ -n '' ]] +++ _main_complete:208 @_main_complete:208> _complete ++++ _complete:7 @_complete:7> local comp name oldcontext ret=1 service ++++ _complete:8 @_complete:8> typeset -T curcontext=:complete:: ccarray ++++ _complete:10 @_complete:10> oldcontext=:complete:: ++++ _complete:14 @_complete:14> [[ -n '' ]] ++++ _complete:96 @_complete:96> comp=_first ++++ _complete:97 @_complete:97> [[ -n _first ]] ++++ _complete:98 @_complete:98> service=-first- ++++ _complete:99 @_complete:99> ccarray[3]=-first- ++++ _complete:100 @_complete:100> eval _first +++++ _complete:101 @(eval):0> _first ++++ _complete:100 @_complete:100> ret=0 ++++ _complete:101 @_complete:101> [[ '' = all ]] ++++ _complete:110 @_complete:110> [[ -n '' ]] ++++ _complete:114 @_complete:114> ret=1 ++++ _complete:115 @_complete:115> [[ command = command ]] ++++ _complete:116 @_complete:116> curcontext=:complete:: ++++ _complete:117 @_complete:117> _normal -s +++++ _normal:3 @_normal:3> local _comp_command1 _comp_command2 _comp_command precommand +++++ _normal:4 @_normal:4> local -A opts +++++ _normal:6 @_normal:6> zparseopts -A opts -D - P 'p+:-=precommand' s +++++ _normal:7 @_normal:7> (( 1 )) +++++ _normal:8 @_normal:8> (( 0 )) +++++ _normal:9 @_normal:9> (( 0 )) +++++ _normal:15 @_normal:15> [[ -o BANG_HIST && '' = !*: || '' = "!*: ]] +++++ _normal:28 @_normal:28> [[ CURRENT -eq 1 ]] +++++ _normal:37 @_normal:37> _set_command ++++++ _set_command:6 @_set_command:6> local command ++++++ _set_command:8 @_set_command:8> command=znap ++++++ _set_command:10 @_set_command:10> [[ -z znap ]] ++++++ _set_command:12 @_set_command:12> (( 0 + 1 )) ++++++ _set_command:13 @_set_command:13> _comp_command1=znap ++++++ _set_command:14 @_set_command:14> _comp_command=znap +++++ _normal:39 @_normal:39> _dispatch -s znap znap '' -default- ++++++ _dispatch:3 @_dispatch:3> local comp pat val name i ret=1 _compskip='' ++++++ _dispatch:4 @_dispatch:4> local curcontext=:complete:: service str noskip ++++++ _dispatch:5 @_dispatch:5> local -a match mbegin mend ++++++ _dispatch:9 @_dispatch:9> [[ -s = -s ]] ++++++ _dispatch:10 @_dispatch:10> noskip=yes ++++++ _dispatch:11 @_dispatch:11> shift ++++++ _dispatch:14 @_dispatch:14> [[ -z yes ]] ++++++ _dispatch:16 @_dispatch:16> curcontext=:complete:znap: ++++++ _dispatch:18 @_dispatch:18> shift ++++++ _dispatch:22 @_dispatch:22> [[ '' != (all|*patterns*) ]] ++++++ _dispatch:24 @_dispatch:24> str=znap ++++++ _dispatch:25 @_dispatch:25> [[ -n znap ]] ++++++ _dispatch:26 @_dispatch:26> service=znap ++++++ _dispatch:24 @_dispatch:24> str= ++++++ _dispatch:25 @_dispatch:25> [[ -n '' ]] ++++++ _dispatch:25 @_dispatch:25> continue ++++++ _dispatch:24 @_dispatch:24> str=-default- ++++++ _dispatch:25 @_dispatch:25> [[ -n -default- ]] ++++++ _dispatch:26 @_dispatch:26> service=-default- ++++++ _dispatch:45 @_dispatch:45> ret=1 ++++++ _dispatch:46 @_dispatch:46> str=znap ++++++ _dispatch:47 @_dispatch:47> [[ -n znap ]] ++++++ _dispatch:51 @_dispatch:51> str=znap ++++++ _dispatch:52 @_dispatch:52> name=znap ++++++ _dispatch:53 @_dispatch:53> comp='' ++++++ _dispatch:54 @_dispatch:54> service=znap ++++++ _dispatch:56 @_dispatch:56> [[ -z '' ]] ++++++ _dispatch:46 @_dispatch:46> str= ++++++ _dispatch:47 @_dispatch:47> [[ -n '' ]] ++++++ _dispatch:47 @_dispatch:47> continue ++++++ _dispatch:46 @_dispatch:46> str=-default- ++++++ _dispatch:47 @_dispatch:47> [[ -n -default- ]] ++++++ _dispatch:51 @_dispatch:51> str=-default- ++++++ _dispatch:52 @_dispatch:52> name=-default- ++++++ _dispatch:53 @_dispatch:53> comp=_default ++++++ _dispatch:54 @_dispatch:54> service=-default- ++++++ _dispatch:56 @_dispatch:56> [[ -z _default ]] ++++++ _dispatch:56 @_dispatch:56> break ++++++ _dispatch:61 @_dispatch:61> [[ -n _default && -default- != -default- ]] ++++++ _dispatch:67 @_dispatch:67> [[ '' != (all|*patterns*) ]] ++++++ _dispatch:68 @_dispatch:68> str=znap ++++++ _dispatch:69 @_dispatch:69> [[ -n znap ]] ++++++ _dispatch:70 @_dispatch:70> service=znap ++++++ _dispatch:68 @_dispatch:68> str= ++++++ _dispatch:69 @_dispatch:69> [[ -n '' ]] ++++++ _dispatch:69 @_dispatch:69> continue ++++++ _dispatch:68 @_dispatch:68> str=-default- ++++++ _dispatch:69 @_dispatch:69> [[ -n -default- ]] ++++++ _dispatch:70 @_dispatch:70> service=-default- ++++++ _dispatch:84 @_dispatch:84> [[ -default- = -default- && -n _default && '' != (all|*default*) ]] ++++++ _dispatch:86 @_dispatch:86> service=-default- ++++++ _dispatch:87 @_dispatch:87> eval _default +++++++ _dispatch:88 @(eval):0> _default ++++++++ _default:3 @_default:3> local ctl ++++++++ _default:5 @_default:5> zstyle -s :completion::complete:znap:: use-compctl ctl ++++++++ _default:6 @_default:6> zmodload -e zsh/compctl ++++++++ _default:15 @_default:15> _files +++++++++ _files:3 @_files:3> local -a match mbegin mend +++++++++ _files:4 @_files:4> local ret=1 +++++++++ _files:8 @_files:8> _have_glob_qual ++++++++++ _have_glob_qual:14 @_have_glob_qual:14> local complete ++++++++++ _have_glob_qual:16 @_have_glob_qual:16> [[ '' = complete ]] ++++++++++ _have_glob_qual:18 @_have_glob_qual:18> [[ -z '' && on == on && '' = (#b)(((*[^\\\$]|)(\\\\)#)\()([^\)\|\~]#) || on == on && '' = (#b)(((*[^\\\$]|)(\\\\)#)\(\#q)([^\)]#) ]] +++++++++ _files:20 @_files:20> [[ on == on && '' = \(\#[^\)]# ]] +++++++++ _files:26 @_files:26> local opts tmp glob pat pats expl tag i def descr end ign tried +++++++++ _files:27 @_files:27> local type sdef ignvars ignvar prepath oprefix rfiles rfile +++++++++ _files:29 @_files:29> zparseopts -a opts '/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: x+: X+: M+: F: J+: V+: o+: +++++++++ _files:32 @_files:32> type='' +++++++++ _files:33 @_files:33> (( 0 )) +++++++++ _files:41 @_files:41> [[ '' = */* ]] +++++++++ _files:44 @_files:44> tmp=0 +++++++++ _files:45 @_files:45> (( tmp )) +++++++++ _files:59 @_files:59> ign=( ) +++++++++ _files:62 @_files:62> zstyle -a :completion::complete:znap:: file-patterns tmp +++++++++ _files:72 @_files:72> zstyle -t :completion::complete:znap:: list-dirs-first +++++++++ _files:77 @_files:77> pats=( '*:globbed-files *(-/):directories' '*:all-files ' ) +++++++++ _files:80 @_files:80> tried=( ) +++++++++ _files:81 @_files:81> def=*:globbed-files *(-/):directories +++++++++ _files:82 @_files:82> eval 'def=( \*:globbed-files \*\(-/\):directories )' ++++++++++ _files:83 @(eval):0> def=( '*:globbed-files' '*(-/):directories' ) +++++++++ _files:84 @_files:84> tmp='*: *(-/):' +++++++++ _files:85 @_files:85> (( 0 )) +++++++++ _files:86 @_files:86> tried=( '*: *(-/):' ) +++++++++ _files:88 @_files:88> sdef=*:globbed-files +++++++++ _files:90 @_files:90> tag=globbed-files +++++++++ _files:91 @_files:91> pat='*' +++++++++ _files:93 @_files:93> [[ '*:globbed-files' = *:globbed-files:* ]] +++++++++ _files:96 @_files:96> (( 0 )) +++++++++ _files:99 @_files:99> descr=file +++++++++ _files:101 @_files:101> end=yes +++++++++ _files:104 @_files:104> _tags globbed-files ++++++++++ _tags:3 @_tags:3> local prev ++++++++++ _tags:10 @_tags:10> [[ globbed-files = -- ]] ++++++++++ _tags:15 @_tags:15> (( 1 )) ++++++++++ _tags:19 @_tags:19> local curcontext=:complete:znap: order tag nodef tmp ++++++++++ _tags:21 @_tags:21> [[ globbed-files = -C?* ]] ++++++++++ _tags:24 @_tags:24> [[ globbed-files = -C ]] ++++++++++ _tags:29 @_tags:29> [[ globbed-files = -(|-) ]] ++++++++++ _tags:31 @_tags:31> zstyle -a :completion::complete:znap:: group-order order ++++++++++ _tags:36 @_tags:36> comptags -i :complete:znap: globbed-files ++++++++++ _tags:40 @_tags:40> [[ -n '' ]] ++++++++++ _tags:43 @_tags:43> zstyle -a :completion::complete:znap:: tag-order order ++++++++++ _tags:44 @_tags:44> (( ! 0 )) ++++++++++ _tags:55 @_tags:55> [[ -z '' ]] ++++++++++ _tags:55 @_tags:55> comptry globbed-files ++++++++++ _tags:60 @_tags:60> comptags -T ++++++++++ _tags:62 @_tags:62> return +++++++++ _files:105 @_files:105> _tags ++++++++++ _tags:3 @_tags:3> local prev ++++++++++ _tags:10 @_tags:10> [[ '' = -- ]] ++++++++++ _tags:15 @_tags:15> (( 0 )) ++++++++++ _tags:67 @_tags:67> comptags -N +++++++++ _files:106 @_files:106> _comp_ignore=( ) +++++++++ _files:107 @_files:107> _next_label globbed-files expl file ++++++++++ _next_label:3 @_next_label:3> local __gopt __descr __spec ++++++++++ _next_label:5 @_next_label:5> __gopt=( ) ++++++++++ _next_label:6 @_next_label:6> zparseopts -D -a __gopt 1 2 V J x ++++++++++ _next_label:8 @_next_label:8> comptags -A globbed-files curtag __spec ++++++++++ _next_label:9 @_next_label:9> (( 10 > _tags_level )) ++++++++++ _next_label:9 @_next_label:9> _comp_tags='' ++++++++++ _next_label:10 @_next_label:10> _tags_level=10 ++++++++++ _next_label:11 @_next_label:11> _comp_tags=' globbed-files ' ++++++++++ _next_label:12 @_next_label:12> [[ globbed-files = *[^\\]:* ]] ++++++++++ _next_label:18 @_next_label:18> _description globbed-files expl file +++++++++++ _description:3 @_description:3> local name nopt xopt format gname hidden hide match opts tag +++++++++++ _description:4 @_description:4> local -a ign gropt sort +++++++++++ _description:6 @_description:6> opts=( ) +++++++++++ _description:8 @_description:8> xopt=( -X ) +++++++++++ _description:9 @_description:9> nopt=( ) +++++++++++ _description:10 @_description:10> zparseopts -K -D -a nopt 1 2 'V=gropt' 'J=ign' 'x=xopt' +++++++++++ _description:12 @_description:12> 3=file +++++++++++ _description:13 @_description:13> [[ -n file ]] +++++++++++ _description:13 @_description:13> _lastdescr=( '' file ) +++++++++++ _description:15 @_description:15> zstyle -s :completion::complete:znap::globbed-files group-name gname +++++++++++ _description:18 @_description:18> _setup globbed-files -default- ++++++++++++ _setup:3 @_setup:3> local val nm=0 ++++++++++++ _setup:5 @_setup:5> [[ 2 -eq 1 ]] ++++++++++++ _setup:7 @_setup:7> zstyle -a :completion::complete:znap::globbed-files list-colors val ++++++++++++ _setup:21 @_setup:21> [[ globbed-files = default ]] ++++++++++++ _setup:27 @_setup:27> zstyle -s :completion::complete:znap::globbed-files show-ambiguity val ++++++++++++ _setup:32 @_setup:32> zstyle -t :completion::complete:znap::globbed-files list-packed ++++++++++++ _setup:34 @_setup:34> [[ 2 -eq 1 ]] ++++++++++++ _setup:37 @_setup:37> compstate[list]=ambiguous ++++++++++++ _setup:40 @_setup:40> zstyle -t :completion::complete:znap::globbed-files list-rows-first ++++++++++++ _setup:42 @_setup:42> [[ 2 -eq 1 ]] ++++++++++++ _setup:45 @_setup:45> compstate[list]=ambiguous ++++++++++++ _setup:48 @_setup:48> zstyle -t :completion::complete:znap::globbed-files last-prompt ++++++++++++ _setup:50 @_setup:50> [[ 2 -eq 1 ]] ++++++++++++ _setup:53 @_setup:53> compstate[last_prompt]=yes ++++++++++++ _setup:56 @_setup:56> zstyle -t :completion::complete:znap::globbed-files accept-exact ++++++++++++ _setup:58 @_setup:58> [[ 2 -eq 1 ]] ++++++++++++ _setup:61 @_setup:61> compstate[exact]='' ++++++++++++ _setup:64 @_setup:64> [[ _last_nmatches -ge 0 && _last_nmatches -ne nm ]] ++++++++++++ _setup:67 @_setup:67> zstyle -a :completion::complete:znap::globbed-files menu val ++++++++++++ _setup:68 @_setup:68> _last_nmatches=0 ++++++++++++ _setup:69 @_setup:69> _last_menu_style=( select ) ++++++++++++ _setup:74 @_setup:74> [[ '' != always ]] ++++++++++++ _setup:75 @_setup:75> zstyle -s :completion::complete:znap::globbed-files force-list val +++++++++++ _description:20 @_description:20> name=expl +++++++++++ _description:22 @_description:22> zstyle -s :completion::complete:znap::globbed-files format format +++++++++++ _description:23 @_description:23> zstyle -s :completion::complete:znap::descriptions format format +++++++++++ _description:25 @_description:25> zstyle -s :completion::complete:znap::globbed-files hidden hidden +++++++++++ _description:30 @_description:30> zstyle -s :completion::complete:znap::globbed-files matcher match +++++++++++ _description:32 @_description:32> [[ -n '' ]] +++++++++++ _description:36 @_description:36> [[ -z '' ]] +++++++++++ _description:37 @_description:37> zstyle -a :completion::complete:znap::globbed-files sort sort +++++++++++ _description:38 @_description:38> zstyle -a :completion::complete:znap:: sort sort +++++++++++ _description:50 @_description:50> [[ -z '' ]] +++++++++++ _description:51 @_description:51> zstyle -a :completion::complete:znap::globbed-files ignored-patterns _comp_ignore +++++++++++ _description:52 @_description:52> _comp_ignore=( ) +++++++++++ _description:54 @_description:54> zstyle -s :completion::complete:znap::globbed-files ignore-line hidden +++++++++++ _description:70 @_description:70> (( 0 )) +++++++++++ _description:75 @_description:75> tag=globbed-files +++++++++++ _description:77 @_description:77> shift 2 +++++++++++ _description:78 @_description:78> [[ -z file ]] +++++++++++ _description:80 @_description:80> [[ -n '' ]] +++++++++++ _description:84 @_description:84> [[ -n '' ]] +++++++++++ _description:91 @_description:91> [[ -n '' ]] +++++++++++ _description:94 @_description:94> set -A expl -J -default- +++++++++++ _description:98 @_description:98> (( 0 )) +++++++++++ _description:99 @_description:99> local fakestyle descr +++++++++++ _description:100 @_description:100> fakestyle=fake +++++++++++ _description:101 @_description:101> zstyle -a :completion::complete:znap::globbed-files fake match +++++++++++ _description:102 @_description:102> continue +++++++++++ _description:100 @_description:100> fakestyle=fake-always +++++++++++ _description:101 @_description:101> zstyle -a :completion::complete:znap::globbed-files fake-always match +++++++++++ _description:102 @_description:102> continue +++++++++++ _description:115 @_description:115> return 0 ++++++++++ _next_label:19 @_next_label:19> set -A expl -J -default- ++++++++++ _next_label:22 @_next_label:22> return 0 +++++++++ _files:108 @_files:108> _comp_ignore=( ) +++++++++ _files:109 @_files:109> [[ -n yes ]] +++++++++ _files:110 @_files:110> _path_files -g '*' -J -default- ++++++++++ _path_files:3 @_path_files:3> local -a match mbegin mend ++++++++++ _path_files:5 @_path_files:5> local splitchars ++++++++++ _path_files:6 @_path_files:6> zstyle -s :completion::complete:znap:: file-split-chars splitchars ++++++++++ _path_files:22 @_path_files:22> _have_glob_qual +++++++++++ _have_glob_qual:14 @_have_glob_qual:14> local complete +++++++++++ _have_glob_qual:16 @_have_glob_qual:16> [[ '' = complete ]] +++++++++++ _have_glob_qual:18 @_have_glob_qual:18> [[ -z '' && on == on && '' = (#b)(((*[^\\\$]|)(\\\\)#)\()([^\)\|\~]#) || on == on && '' = (#b)(((*[^\\\$]|)(\\\\)#)\(\#q)([^\)]#) ]] ++++++++++ _path_files:44 @_path_files:44> local linepath realpath donepath prepath testpath exppath skips skipped ++++++++++ _path_files:45 @_path_files:45> local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre ++++++++++ _path_files:46 @_path_files:46> local pats haspats ignore pfx pfxsfx sopt gopt opt sdirs ignpar cfopt listsfx ++++++++++ _path_files:47 @_path_files:47> local nm=0 menu matcher mopts sort mid accex fake ++++++++++ _path_files:48 @_path_files:48> local listfiles listopts tmpdisp origtmp1 Uopt ++++++++++ _path_files:49 @_path_files:49> local accept_exact_dirs path_completion ++++++++++ _path_files:50 @_path_files:50> integer npathcheck ++++++++++ _path_files:51 @_path_files:51> local -a Mopts ++++++++++ _path_files:53 @_path_files:53> typeset -U prepaths exppaths ++++++++++ _path_files:55 @_path_files:55> exppaths=( ) ++++++++++ _path_files:59 @_path_files:59> zparseopts -a mopts 'P:=pfx' 'S:=pfxsfx' 'q=pfxsfx' 'r:=pfxsfx' 'R:=pfxsfx' 'W:=prepaths' 'F:=ignore' 'M+:=matcher' J+: V+: x+: X+: 1 2 o+: n 'f=tmp1' '/=tmp1' 'g+:-=tmp1' ++++++++++ _path_files:64 @_path_files:64> sopt=-g ++++++++++ _path_files:65 @_path_files:65> (( 1 )) ++++++++++ _path_files:65 @_path_files:65> haspats=yes ++++++++++ _path_files:66 @_path_files:66> (( 1 )) ++++++++++ _path_files:66 @_path_files:66> gopt=yes ++++++++++ _path_files:67 @_path_files:67> (( 0 )) ++++++++++ _path_files:71 @_path_files:71> pats='*' ++++++++++ _path_files:72 @_path_files:72> pats=( '*' ) ++++++++++ _path_files:74 @_path_files:74> pats=( '*' ) ++++++++++ _path_files:76 @_path_files:76> (( 0 )) ++++++++++ _path_files:80 @_path_files:80> (( 0 )) ++++++++++ _path_files:92 @_path_files:92> prepaths=( '' ) ++++++++++ _path_files:95 @_path_files:95> (( 0 )) ++++++++++ _path_files:106 @_path_files:106> [[ -g = -(f|) ]] ++++++++++ _path_files:115 @_path_files:115> (( ! 1 )) ++++++++++ _path_files:136 @_path_files:136> [[ -z '' && 0 -eq 0 && -z yes || '*' = \ #\*\ # && -n '' ]] ++++++++++ _path_files:140 @_path_files:140> (( 0 )) ++++++++++ _path_files:145 @_path_files:145> [[ 0 -eq 0 && -o nocaseglob ]] ++++++++++ _path_files:151 @_path_files:151> (( 0 )) ++++++++++ _path_files:156 @_path_files:156> zstyle -s :completion::complete:znap:: file-sort tmp1 ++++++++++ _path_files:191 @_path_files:191> zstyle -t :completion::complete:znap::paths squeeze-slashes ++++++++++ _path_files:194 @_path_files:194> skips='((.|..)/)##' ++++++++++ _path_files:197 @_path_files:197> zstyle -s :completion::complete:znap::paths special-dirs sdirs ++++++++++ _path_files:198 @_path_files:198> zstyle -t :completion::complete:znap::paths list-suffixes ++++++++++ _path_files:201 @_path_files:201> [[ '*' = ((|*[[:blank:]])\*(|[[:blank:]]*|\([^[:blank:]]##\))|*\([^[:blank:]]#/[^[:blank:]]#\)*) ]] ++++++++++ _path_files:202 @_path_files:202> sopt=-g/ ++++++++++ _path_files:204 @_path_files:204> zstyle -a :completion::complete:znap::paths accept-exact accex ++++++++++ _path_files:205 @_path_files:205> zstyle -a :completion::complete:znap:: fake-files fake ++++++++++ _path_files:207 @_path_files:207> zstyle -s :completion::complete:znap:: ignore-parents ignpar ++++++++++ _path_files:209 @_path_files:209> zstyle -t :completion::complete:znap::paths accept-exact-dirs ++++++++++ _path_files:211 @_path_files:211> zstyle -T :completion::complete:znap::paths path-completion ++++++++++ _path_files:212 @_path_files:212> path_completion=1 ++++++++++ _path_files:214 @_path_files:214> [[ -n '' ]] ++++++++++ _path_files:242 @_path_files:242> pre='' ++++++++++ _path_files:243 @_path_files:243> suf='' ++++++++++ _path_files:244 @_path_files:244> opre='' ++++++++++ _path_files:245 @_path_files:245> osuf='' ++++++++++ _path_files:246 @_path_files:246> orig='' ++++++++++ _path_files:247 @_path_files:247> eorig='' ++++++++++ _path_files:249 @_path_files:249> [[ automenu-unambiguous = (*menu|[0-9]*) || -n '' || -n '' ]] ++++++++++ _path_files:252 @_path_files:252> [[ -n '' ]] ++++++++++ _path_files:256 @_path_files:256> Mopts=( -M 'r:|/=* r:|=*' ) ++++++++++ _path_files:261 @_path_files:261> [[ '' = [^][*?#^\|\<\>\\]#(`[^`]#`|\$)*/* ]] ++++++++++ _path_files:282 @_path_files:282> [[ '' = \~ ]] ++++++++++ _path_files:332 @_path_files:332> linepath='' ++++++++++ _path_files:333 @_path_files:333> realpath='' ++++++++++ _path_files:335 @_path_files:335> zstyle -s :completion::complete:znap:: preserve-prefix tmp1 ++++++++++ _path_files:343 @_path_files:343> [[ '' = / ]] ++++++++++ _path_files:356 @_path_files:356> [[ '' = (.|..)/* ]] ++++++++++ _path_files:357 @_path_files:357> donepath='' ++++++++++ _path_files:364 @_path_files:364> prepath= ++++++++++ _path_files:370 @_path_files:370> skipped='' ++++++++++ _path_files:371 @_path_files:371> cpre='' ++++++++++ _path_files:373 @_path_files:373> [[ -n '' || -z 1 ]] ++++++++++ _path_files:412 @_path_files:412> tpre='' ++++++++++ _path_files:413 @_path_files:413> tsuf='' ++++++++++ _path_files:421 @_path_files:421> testpath='' ++++++++++ _path_files:423 @_path_files:423> tmp2='' ++++++++++ _path_files:424 @_path_files:424> tpre='' ++++++++++ _path_files:426 @_path_files:426> tmp1=( '' ) ++++++++++ _path_files:429 @_path_files:429> (( npathcheck = 0 )) ++++++++++ _path_files:430 @_path_files:430> true ++++++++++ _path_files:432 @_path_files:432> origtmp1=( '' ) ++++++++++ _path_files:435 @_path_files:435> [[ '' = */* ]] ++++++++++ _path_files:439 @_path_files:439> PREFIX='' ++++++++++ _path_files:440 @_path_files:440> SUFFIX='' ++++++++++ _path_files:452 @_path_files:452> tmp2=( '' ) ++++++++++ _path_files:454 @_path_files:454> [[ '' = (#b)*/(*) ]] ++++++++++ _path_files:467 @_path_files:467> [[ -g/ = *[/f]* ]] ++++++++++ _path_files:468 @_path_files:468> compfiles -p tmp1 accex '' ' ' '' fake '*' ++++++++++ _path_files:472 @_path_files:472> tmp1=( Applications 'Applications (Parallels)' Desktop Documents Downloads Library Movies Music Parallels Pictures Public bin fossil lib org src tmp ) ++++++++++ _path_files:474 @_path_files:474> [[ -n '' ]] ++++++++++ _path_files:546 @_path_files:546> (( ! 17 )) ++++++++++ _path_files:575 @_path_files:575> [[ -n '' ]] ++++++++++ _path_files:589 @_path_files:589> [[ '' = */* ]] ++++++++++ _path_files:591 @_path_files:591> [[ '' = */* ]] ++++++++++ _path_files:595 @_path_files:595> break ++++++++++ _path_files:614 @_path_files:614> tmp3='' ++++++++++ _path_files:615 @_path_files:615> tpre='' ++++++++++ _path_files:616 @_path_files:616> tsuf='' ++++++++++ _path_files:617 @_path_files:617> [[ -n '' ]] ++++++++++ _path_files:627 @_path_files:627> true ++++++++++ _path_files:634 @_path_files:634> compfiles -r tmp1 '' ++++++++++ _path_files:635 @_path_files:635> tmp4=1 ++++++++++ _path_files:637 @_path_files:637> [[ '' = */* ]] ++++++++++ _path_files:642 @_path_files:642> tmp2='' ++++++++++ _path_files:643 @_path_files:643> PREFIX='' ++++++++++ _path_files:644 @_path_files:644> SUFFIX='' ++++++++++ _path_files:651 @_path_files:651> (( tmp4 )) ++++++++++ _path_files:660 @_path_files:660> tmp2='' ++++++++++ _path_files:661 @_path_files:661> [[ -n '' ]] ++++++++++ _path_files:663 @_path_files:663> [[ -n '' ]] ++++++++++ _path_files:667 @_path_files:667> compquote tmp1 tmp2 ++++++++++ _path_files:670 @_path_files:670> [[ -z '' && '' = \* ]] ++++++++++ _path_files:680 @_path_files:680> [[ -z automenu-unambiguous ]] ++++++++++ _path_files:681 @_path_files:681> zstyle -t :completion::complete:znap::paths expand suffix ++++++++++ _path_files:682 @_path_files:682> [[ -z '' && -n '' || -z '' ]] ++++++++++ _path_files:688 @_path_files:688> (( tmp4 )) ++++++++++ _path_files:688 @_path_files:688> zstyle -t :completion::complete:znap::paths ambiguous ++++++++++ _path_files:690 @_path_files:690> [[ '' = */* ]] ++++++++++ _path_files:716 @_path_files:716> _list_files tmp1 '' +++++++++++ _list_files:11 @_list_files:11> local stat f elt what dir +++++++++++ _list_files:12 @_list_files:12> local -a stylevals +++++++++++ _list_files:13 @_list_files:13> integer ok +++++++++++ _list_files:15 @_list_files:15> listfiles=( ) +++++++++++ _list_files:16 @_list_files:16> listopts=( ) +++++++++++ _list_files:18 @_list_files:18> zstyle -a :completion::complete:znap:: file-list stylevals +++++++++++ _list_files:18 @_list_files:18> return 1 ++++++++++ _path_files:717 @_path_files:717> compadd -Qf -J -default- -p '' -s '' -W '' -M 'r:|/=* r:|=*' -a tmp1 ++++++++++ _path_files:754 @_path_files:754> tmp4=- ++++++++++ _path_files:756 @_path_files:756> break ++++++++++ _path_files:800 @_path_files:800> [[ -z - ]] ++++++++++ _path_files:886 @_path_files:886> [[ _matcher_num -eq 1 ]] ++++++++++ _path_files:887 @_path_files:887> zstyle -t :completion::complete:znap::paths expand prefix ++++++++++ _path_files:895 @_path_files:895> [[ nm -ne 'compstate[nmatches]' ]] +++++++++ _files:111 @_files:111> ret=0 +++++++++ _files:107 @_files:107> _next_label globbed-files expl file ++++++++++ _next_label:3 @_next_label:3> local __gopt __descr __spec ++++++++++ _next_label:5 @_next_label:5> __gopt=( ) ++++++++++ _next_label:6 @_next_label:6> zparseopts -D -a __gopt 1 2 V J x ++++++++++ _next_label:8 @_next_label:8> comptags -A globbed-files curtag __spec ++++++++++ _next_label:25 @_next_label:25> return 1 +++++++++ _files:133 @_files:133> (( ret )) +++++++++ _files:133 @_files:133> break +++++++++ _files:140 @_files:140> [[ '*' = \* ]] +++++++++ _files:140 @_files:140> return ret ++++++++ _default:15 @_default:15> return 0 ++++++ _dispatch:87 @_dispatch:87> ret=0 ++++++ _dispatch:89 @_dispatch:89> _compskip='' ++++++ _dispatch:91 @_dispatch:91> return ret ++++ _complete:117 @_complete:117> ret=0 ++++ _complete:142 @_complete:142> _compskip='' ++++ _complete:144 @_complete:144> return ret +++ _main_complete:209 @_main_complete:209> ret=0 +++ _main_complete:210 @_main_complete:210> break 2 +++ _main_complete:219 @_main_complete:219> curcontext=::: +++ _main_complete:220 @_main_complete:220> [[ '' = keep ]] +++ _main_complete:226 @_main_complete:226> nm=17 +++ _main_complete:229 @_main_complete:229> [[ '' = keep || nm -gt 1 ]] +++ _main_complete:230 @_main_complete:230> [[ _last_nmatches -ge 0 && _last_nmatches -ne nm ]] +++ _main_complete:231 @_main_complete:231> _menu_style=( select '' ) +++ _main_complete:233 @_main_complete:233> tmp=7 +++ _main_complete:235 @_main_complete:235> _menu_style=( select '' select ) +++ _main_complete:237 @_main_complete:237> [[ ambiguous = *list ]] +++ _main_complete:241 @_main_complete:241> [[ automenu-unambiguous = automenu-unambiguous ]] +++ _main_complete:242 @_main_complete:242> [[ -n automenu-unambiguous && -n '' ]] +++ _main_complete:246 @_main_complete:246> sel=( ) +++ _main_complete:248 @_main_complete:248> (( 0 )) +++ _main_complete:264 @_main_complete:264> sel=( ) +++ _main_complete:266 @_main_complete:266> (( 0 )) +++ _main_complete:282 @_main_complete:282> [[ -n '' || -n '' ]] +++ _main_complete:286 @_main_complete:286> [[ -n '' ]] +++ _main_complete:288 @_main_complete:288> [[ -n '' ]] +++ _main_complete:295 @_main_complete:295> [[ automenu-unambiguous = *menu* ]] +++ _main_complete:296 @_main_complete:296> [[ 0 = 00 ]] +++ _main_complete:297 @_main_complete:297> [[ -n '' ]] +++ _main_complete:299 @_main_complete:299> [[ -n '' ]] +++ _main_complete:305 @_main_complete:305> [[ 0 != 00 ]] +++ _main_complete:306 @_main_complete:306> sel=( select select ) +++ _main_complete:308 @_main_complete:308> (( 2 )) +++ _main_complete:309 @_main_complete:309> min=9999999 +++ _main_complete:310 @_main_complete:310> i=select +++ _main_complete:311 @_main_complete:311> [[ select = *=[0-9]* ]] +++ _main_complete:314 @_main_complete:314> [[ select != *=* ]] +++ _main_complete:315 @_main_complete:315> num=0 +++ _main_complete:319 @_main_complete:319> [[ num -lt min ]] +++ _main_complete:319 @_main_complete:319> min=0 +++ _main_complete:321 @_main_complete:321> (( min )) +++ _main_complete:321 @_main_complete:321> break +++ _main_complete:324 @_main_complete:324> zmodload -i zsh/complist +++ _main_complete:325 @_main_complete:325> MENUSELECT=0 +++ _main_complete:330 @_main_complete:330> [[ -n 0 ]] +++ _main_complete:331 @_main_complete:331> [[ -n '' ]] +++ _main_complete:333 @_main_complete:333> [[ -n '' ]] +++ _main_complete:340 @_main_complete:340> unset MENUMODE +++ _main_complete:367 @_main_complete:367> [[ -n '' ]] +++ _main_complete:374 @_main_complete:374> [[ '' = always || '' = ?* ]] +++ _main_complete:380 @_main_complete:380> [[ '' = keep ]] +++ _main_complete:386 @_main_complete:386> (( 0 )) +++ _main_complete:389 @_main_complete:389> unset ZLS_COLORS +++ _main_complete:395 @_main_complete:395> funcs=( ) +++ _main_complete:396 @_main_complete:396> comppostfuncs=( ) +++ _main_complete:401 @_main_complete:401> _lastcomp=( list_lines 5 all_quotes '\' nmatches 17 restore auto context command vared '' unambiguous '' list_max 100 unambiguous_cursor 1 list ambiguous insert_positions 5 unambiguous_positions 0 exact '' to_end match last_prompt yes pattern_insert menu ignored 0 insert automenu-unambiguous ) +++ _main_complete:402 @_main_complete:402> _lastcomp[nmatches]=17 +++ _main_complete:403 @_main_complete:403> _lastcomp[completer]=complete +++ _main_complete:404 @_main_complete:404> _lastcomp[prefix]='' +++ _main_complete:405 @_main_complete:405> _lastcomp[suffix]='' +++ _main_complete:406 @_main_complete:406> _lastcomp[iprefix]='' +++ _main_complete:407 @_main_complete:407> _lastcomp[isuffix]='' +++ _main_complete:408 @_main_complete:408> _lastcomp[qiprefix]='' +++ _main_complete:409 @_main_complete:409> _lastcomp[qisuffix]='' +++ _main_complete:410 @_main_complete:410> _lastcomp[tags]=' globbed-files ' +++ _main_complete:412 @_main_complete:412> return ret znap Applications/ Library/ Public/ [...] ```
marlonrichert commented 3 years ago
❯ print $_comps[znap]

~

This means that Znap's completion function has not been loaded by compinit, which is confirmed by the rest of the output.

Please check the output of env and print -l $fpath before and after you restart. Are there any differences?

thk-gh commented 3 years ago

No differences in env or $fpath between znap restarts.

❯ print -l $fpath
/Users/thk/src/zsh/pure /usr/local/share/zsh/site-functions /usr/share/zsh/site-functions /usr/share/zsh/5.8/functions /Users/thk/.local/share/zsh/site-functions

❯ ls -l /Users/thk/.local/share/zsh/site-functions/
total 16 lrwxr-xr-x 1 thk staff 43 Nov 3 22:00 _znap@ -> /Users/thk/src/zsh/zsh-snap/functions/_znap -rw-r----- 1 thk staff 5984 Nov 2 12:48 _znap.zwc

❯ ls -l /Users/thk/src/zsh/zsh-snap/functions/_znap -rw-r--r-- 1 thk staff 2064 Nov 2 12:47 /Users/thk/src/zsh/zsh-snap/functions/_znap

thk-gh commented 3 years ago

I just found the cause.

I have these lines in my .zshenv I had forgotten about.

source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc'                                     
source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc' 

Apparently brew cask info google-cloud-sdk told me to put them there some time ago.

The second line (.../completion.zsh.inc) causes the phenomenon; if I comment it out the problem disappears. Of course, now gcloud [TAB] doesn't work anymore... :-) I'll try to find a workaround or solution or I just live with it.

So, thank you very much for your help, very much appreciated, great support!

In case you are still interested, here is the completion.zsh.inc file from Google's Cloud SDK:

autoload -U +X bashcompinit && bashcompinit
zmodload -i zsh/parameter
if ! (( $+functions[compdef] )) ; then
    autoload -U +X compinit && compinit
fi

_python_argcomplete() {
    local prefix=
    if [[ $COMP_LINE == 'gcloud '* ]]; then
        if [[ $3 == ssh  && $2 == *@* ]] ;then
            # handle ssh user@instance specially
            prefix=${2%@*}@
            COMP_LINE=${COMP_LINE%$2}"${2#*@}"
        elif [[ $2 == *'='* ]] ; then
            # handle --flag=value
            prefix=${2%=*}'='
            COMP_LINE=${COMP_LINE%$2}${2/'='/' '}
        fi
    fi
    local IFS='^K'
    COMPREPLY=( $(IFS="$IFS"                   COMP_LINE="$COMP_LINE"                   COMP_POINT="$COMP_POINT"        
           _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS"                   _ARGCOMPLETE=1                   "$1" 8>&1 
9>&2 1>/dev/null 2>/dev/null) )
    if [[ $? != 0 ]]; then
        unset COMPREPLY
        return
    fi
    # if one completion without a trailing space, add the space
    if [[ ${#COMPREPLY[@]} == 1 && $COMPREPLY != *[=' '] ]]; then
        COMPREPLY+=' '
    fi
    if [[ $prefix != '' ]]; then
        typeset -i n
        for ((n=0; n < ${#COMPREPLY[@]}; n++));do
            COMPREPLY[$n]=$prefix${COMPREPLY[$n]}
        done
    fi
}
complete -o nospace -o default -F _python_argcomplete "gcloud"

_completer() {
    command=$1
    name=$2
    eval '[[ -n "$'"${name}"'_COMMANDS" ]] || '"${name}"'_COMMANDS="$('"${command}"')"'
    set -- $COMP_LINE
    shift
    while [[ $1 == -* ]]; do
          shift
    done
    [[ -n "$2" ]] && return
    grep -q "${name}\s*$" <<< $COMP_LINE &&
        eval 'COMPREPLY=($'"${name}"'_COMMANDS)' &&
        return
    [[ "$COMP_LINE" == *" " ]] && return
    [[ -n "$1" ]] &&
        eval 'COMPREPLY=($(echo "$'"${name}"'_COMMANDS" | grep ^'"$1"'))'
}

unset bq_COMMANDS
_bq_completer() {
    _completer "CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK=1 bq help | grep '^[^ ][^ ]*  ' | sed 's/ .*//'" bq
}

complete -o default -F _bq_completer bq
complete -o nospace -F _python_argcomplete gsutil
marlonrichert commented 3 years ago

In case you are still interested, here is the completion.zsh.inc file from Google's Cloud SDK:

Wow, that code is so messed up on so many levels, I don't even know where to start to explain what's wrong with it. The people who wrote this don't seem to have any clue what they were doing. Don't use it! It will do you more harm than good.

Instead, add this to your .zshrc file:

# Lazy-load the completion function for these commands.
znap function _python_argcomplete gloud gsutil \
    'eval "$( register-python-argcomplete gloud gsutil )"'

# Cache command output.
bqinit() {
  unfunction bqinit
  typeset -gH BQ_COMMANDS="$(
      CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK=1 bq help |
          grep '^[^ ][^ ]*  ' |
          sed 's/ .*//'
  )"
  typeset -m BQ_COMMANDS
}
znap eval bq bqinit

# Define custom, bash-style completion function.
_bq() {
    set -- $COMP_LINE
    shift
    while [[ $1 == -* ]]; do
          shift
    done
    [[ -n "$2" ]] &&
        return
    grep -q 'bq\s*$' <<< $COMP_LINE &&
        COMPREPLY=( $BQ_COMMANDS ) &&
        return
    [[ "$COMP_LINE" == *' ' ]] &&
        return
    [[ -n "$1" ]] &&
        COMPREPLY=( $( echo "$BQ_COMMANDS" | grep ^"$1" ) )
}

# Register bash-style completions.
complete -o nospace -o default -F _python_argcomplete gcloud
complete -o nospace -F _python_argcomplete gsutil
complete -o default -F _bq bq