Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: More-verbose tab-completion idiom?



On 2022-03-17 at 13:44 -0700, Bart Schaefer wrote:
> Are the key-value pairs at least all on one line each?  Just choosing
> a json file that's lying around on my Ubuntu:

Yes, yes they are.
For now.  And I'm in a position to chat with the tool maintainer and try
to make sure they stay that way.

> json2hash () {
>   zmodload zsh/mapfile
>   setopt localoptions extendedglob
>   # Might have to undo gmail line wrapping here
>   typeset -gA $1=(
> ${(z)${(@)${(f)mapfile[$2]}:#[{}]}/(#b)([^:]#):(*)/${(Q)match[1]}
> ${(q)${(z)${match[2]%,}}}} )
> }
> json2hash scopes /usr/share/unity/client-scopes.json
> typeset -p scopes

Switching from `jq` to this:

  described_contexts+=("${nctx//:/\\:}:${${${${(@M)${(f)mapfile[$nats_ctxdir/$nctx.json]}:#[[:space:]]##\"description\":*}#*: \"}%,}%\"}")

means that the time to complete, across 35 files, drops from "a few
seconds where things appear to have hung" to "faster than I can notice",
so I am going to publish a version using this, and most of Daniel's
suggestions, in a few minutes.  I just have to switch from
"extra-verbose" to "verbose" simply because of the difference in
overhead now.

Thank you!

-Phil




Messages sorted by: Reverse Date, Date, Thread, Author