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

completion as if.



Hey,

For years now people have come to irc and asked a question along the lines of
`how can i get my command to complete like this other command?' and over time
the given answer became to mess with the $words and $CURRENT (and times $service)
parameters before calling the completer that has the desired completion.

_othercommand() { words[1]=(docker run); (( CURRENT++ )); _docker }
compdef _othercommand othercommand

at some point noticing that the _normal function also works at tricking
compsys into doing so.

matthew martin floated the idea of shipping a function with zsh to easily
facilitate this, with something like:

#autoload
local service=$1 words=("$words[@]") CURRENT=$CURRENT
words[1]=("$@")
(( CURRENT += $# - 1 ))
_normal


Does anyone (in particular oliver) see a problem with this approach or
including a potential function with zsh?




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