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

Re: More-verbose tab-completion idiom?



On Wed, Mar 16, 2022 at 5:27 PM Phil Pennock
<zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:
>
> But, I could provide a more detailed description, by parsing the
> .description field from the JSON file.  AFAIK this is going to be
> external shell-outs to jq right now (unless anyone has a solid reliable
> pattern for JSON extraction from a simple KV object in zsh?).

If it's REALLY simple and both keys and values are properly quoted,
you might be able to get away with

() {
  local IFS='{},:'
  typeset -gA context=( ${(Q)=1} )
} "$(<json_context_file)"

but that assumes you don't have colons or commas or braces in the keys
or descriptions.




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