zsh-users
 help / color / mirror / code / Atom feed
* Completion for unknown command
@ 2006-05-18  1:18 John Eikenberry
  0 siblings, 0 replies; only message in thread
From: John Eikenberry @ 2006-05-18  1:18 UTC (permalink / raw)
  To: zsh users


I have a command I'd like to make completions work with. Unlike the other
unknown commands in the wiki this command doesn't complete with files, users,
hosts or arguments. It completes with values read/parsed from a file. The
command is 'cda' and is a zsh function wrapper around cdargs [1]. It is
autoloaded.

I originally thought I would be able to do the completion with a zstyle command
similar to adding ssh hosts. It used the default (all-files) which I didn't
want to extend, so I thought to change that. So I looked into using compdef to
change it from the default, but I couldn't find an appropriate builtin function
to use.

I ended up writing my own completion function to use with compdef [2].
This works, I just thought there would be a easier way to add the
completion via zstyles. Looking at what I have below, does anyone know of a
simpler way?

Thanks for any tips.


[1]
function cda () {
    cdargs -f $CDA_BOOKMARKS -o $CDA_RESULT "$1" && cd "`cat "$CDA_RESULT"`" ;
}


[2]
# $CDA_BOOKMARKS is an env var with the location of the bookmarks file used
# by cdargs.
_cda() { 
    local expl
    local -a cda_bookmarks
    cda_bookmarks=(${${(f)"$(<$CDA_BOOKMARKS)"}%%\ *})
    _wanted cda_bookmarks expl cda compadd -a cda_bookmarks 
}
compdef _cda cda


-- 

John Eikenberry
[jae@zhar.net - http://zhar.net]
______________________________________________________________
"It is difficult to produce a television documentary that is both incisive
and probing when every twelve minutes one is interrupted by twelve dancing
rabbits singing about toilet paper." - Rod Serling


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-05-18  1:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-18  1:18 Completion for unknown command John Eikenberry

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

	https://git.vuxu.org/mirror/zsh/

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