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

Re: completion for function arguments?



Le jeu. 8 août 2019 à 15:08, TJ Luoma <luomat@xxxxxxxxx> a écrit :
> Let me start by saying that I don't understand completion at all,

So, let's start by saying that I don't understand them much either,
and that someone will probably suggest something much simpler using
zstyle.

> I have a function called 'jump' which I will include below.
> The function takes one (1) argument from a specific list of arguments.

The following should work:

_jump() {
  local targets=(macbook imac tyrion)
  _wanted jump_target expl 'Jump target' compadd -a targets
}
compdef  _jump jump

Note that you can achieve the same effect by just putting the
following in a file named _jump somewhere in your $fpath:

#compdef jump
local targets=(macbook imac tyrion)
_wanted jump_target expl 'Jump target' compadd -a targets

As I said, it should work, but there are probably much nicer ways to
achieve the same result.

Best regards,

-- 
Jérémie



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