[darcs-users] zsh completion
Dustin Sallings
dustin at spy.net
Fri Dec 3 18:03:53 UTC 2004
On Dec 2, 2004, at 8:51, Abraham Egnor wrote:
> I was quite happy to see that there's zsh completion code for darcs;
> however, it's lacking in that commands that accept filenames (darcs
> add, for example) don't do filename completion. Not being a zsh guru,
> I don't know offhand how to add this; are there any here who do?
I've got a variety of tcsh completions I do the following way (tla,
aba, darcs, and perforce):
if(! $?darcscommands) then
set darcscommands=()
endif
set darcspath=`which darcs`
if ( $? == 0 ) then
if ( -f $completecache && { test $darcspath -ot $completecache
} ) then
:
else
set updatecache=1
set darcscommands=( \
`darcs | egrep "^ " | awk '{print $1}' | sort
-u ` )
endif
complete darcs 'p/1/$darcscommands/'
endif
[...]
if ($updatecache == 1) then
echo "Updating the completion cache."
rm -f $completecache
touch $completecache
echo "set darcscommands=($darcscommands)" >> $completecache
endif
if ( -f $completecache ) then
source $completecache
endif
It doesn't do anything past the first argument (command), but it's
fully automated and out of my way (as I upgrade darcs or whatever, my
completion rules change), and it's pretty efficient since it caches.
Of course, a custom parser could likely do deeper introspection in
darcs to build a more complete set. The output of --help looks pretty
easy to parse.
--
Dustin Sallings
More information about the darcs-users
mailing list