help / color / mirror / code / Atom feed
* More-verbose tab-completion idiom?
@ 2022-03-17  0:26 Phil Pennock
  2022-03-17  0:50 ` Daniel Shahaf
  2022-03-17  1:20 ` Bart Schaefer
  0 siblings, 2 replies; 11+ messages in thread
From: Phil Pennock @ 2022-03-17  0:26 UTC (permalink / raw)
  To: zsh-users


I have a command (`nats`) which takes a "context", and where that can be
set as an environment variable.  I have tab-completion of these working,
based upon knowing where the contexts are stored.  Each context is a
JSON file in a specific directory, but I mostly only need the name.

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?).

This is relatively expensive and I don't want to do it by default.  I
mean, if most people have at most 3 contexts then it might be sane for
them, but I have 35 and while I might be an outlier, I can believe there
would be people with more.

Is there a standard idiom and keybinding for "go ahead and get the
expensive data, to provide me with more details to choose between the
options", or would I be creating this from scratch?

My completion for this command also gets pointed at by the installer,
so I really want to make sure that what I end up with is not a baroque
Phil Special but instead something which fits better with whatever the
plugin ecosystems are doing, etc.

I know about use-cache etc and have that in other completions of mine,
so if there's no existing idiom for "trigger expensive completion" then
I will use a zstyle to let people request "descriptions" for this
completion, and use-cache if that's set.  I'm asking in case there's a
better way I'm not familiar with.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-03-18  1:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-17  0:26 More-verbose tab-completion idiom? Phil Pennock
2022-03-17  0:50 ` Daniel Shahaf
2022-03-17  1:26   ` Phil Pennock
2022-03-17  1:20 ` Bart Schaefer
2022-03-17  1:24   ` Bart Schaefer
2022-03-17  2:21   ` Phil Pennock
2022-03-17 16:30     ` Daniel Shahaf
2022-03-17 20:44     ` Bart Schaefer
2022-03-17 21:38       ` Phil Pennock
2022-03-18  0:28         ` Daniel Shahaf
2022-03-18  1:16           ` Phil Pennock

Code repositories for project(s) associated with this inbox:


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).