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

ZSH-Completion help



Hey,

I was wondering if it's possible to append variables such as _host or create a custom variable in the arguments array. I just need to append :0.0 and similar things to other variables such as users. I tried to follow:
http://www.linux-mag.com/id/1106
and I used the state variable but it failed for me. Then I tried to use something like:
_myhosts=( ${(f)"$(<~/devel/imp_outs/hosts | sed 's/$/:0.0/')"} )
but that messed up horribly.

Also, I wanted to know how can I create an argument that is a colon separated value of _users. For example, if I use a certain flag I want to be able to do something like:
mycommand -userflag user1:user2:user3
with all the users being tab completed from the _users variable. It should stop when I enter a space.

Another thing I tried to do was get only one command to tab complete so you should only complete one command, so the following would be illegal:
mycommand cmd1 cmd1
mycommand cmd1 cmd2

My code is as follows:
#compdef mycommand

local arguments state


arguments=(

#append :0.0 to this

 '(-d)-d[set display to display]:display:_hosts'

#if this flag is set, none other should complete

 '(-h -a -b -d -g -i -k -m -n -p -r -s -v -w -x)-h[prints help message]'

#needs to continue completion from _users after :

'(-m)-m[email to colon separated value of emails ]:colon separated emails:_users'


#this errors by showing me files too, not just directories after all
#directories have been exhausted in the given path
 '(-p)-p[use PATH as thedirectory]:path:_files -/' 


#only one command should complete with mycommand
 '*:commands:(cmd cmd1 cmd2 cmd3)'
)



So I'm trying to do these things:
mycommand -h <TAB> (shows nothing)
mycommand cmd1 <TAB> (shows nothing)
mycommand -p <TAB> (show directories)
mycommand -d <TAB> (show all hosts appended with :0.0)
mycommand -m user1:<TAB> (shows all users)
____________
dasickis


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