Zsh Mailing List Archive
Messages sorted by:
Re: completion within a function
On 2020-12-29 8:34 p.m., Roman Perepelitsa wrote:
In a function named 'c'. It's my one stop shopping wrapper around
'cd'. Mostly it offers a zcurses based (thanks Sebastian) selection of
previously visited directories from a persistent, global directory stack
, but the code I just added (thanks Bart) now gives me this pseudo
completion like this:
Where and how do you want to invoke this code?
8 /aWorking/Zsh/Source/Wk 4 $ c N- # I could have just pressed TAB
here to complete.
Changing to N-functionsWorking ...
8 /aWorking/Zsh/Source/Wk/N-functionsWorking 4
$ 7:25AM Wed 30
... So before offering a zcurses selection from the directory stack, it
now attempts what would be almost exactly the same as:
$ cd N- [TAB]
... Bart's code just globs " N-* " so " N-functionsWorking " is found
automagically. It's sorta better than TAB anyway because there will be
no mysterious completions. Also actually using TAB on the command line
sometimes gives you several possible completions but as I have it, if
there's only one match it just 'cd's' there, if not, you get the zcurses
selection window. (And of course I still can complete using TAB if I
feel like it anyway, that option remains.) I quite love my 'c' wrapper,
life was solitary, poor, nasty brutish and short without it.
So the idea of invoking completion within a function is now a matter of
curiosity only. Still I'm surprised it can't be done. It's one of
those things where zsh smartness is hard to turn off.
Here's a real life example of 'c' being elegant. Where the hell are my
zsh distribution functions?
8 /aWorking/Zsh/Source/Wk 4 $ c ,a Functions zsh
Searching entire system for directories matching: "Functions" "zsh"
(case INsensitive, WILD) ...
Changing to /aWorking/Zsh/Zsh-5.8/share/zsh/5.8/functions ...
8 /aWorking/Zsh/Zsh-5.8/share/zsh/5.8/functions 4 $ # Sweetly found.
Messages sorted by: