TCSH completion patterns and the pkg command

Stephen Riehm freebsd at opensauce.de
Sun Jan 4 03:10:13 UTC 2015


Hi guys,

>> In my opinion, this is possible, but not easy. I'd say
>> it's easier to teach the C shell the completition rules
>> for the commands you want.

Wise words :-)

> I am not sure it easier to do so.  If we consider the special
> example of git:
> 
> * We have several possible sort of completion lists:
>  remotes, branch names, tags, and commit hashs — the latter
>  are commonly used for git commit --fixup et al.
> * We have a lot of subcommands having many options whose names
>  sometimes collide and do not always use the same arguments
>  (e.g. git diff -b and git checkout -b).
> 
> It seems to me that it is very hard to propose pertinent
> completions for git if we do not take the current subcommand
> into account — but frankly, I did not try very hard.

You're right that the "<utility> [options] <command> [options] <args>"
style which has emerged in recent years is not what most completion
systems were designed to cope with, and to be honest, you'd need a database
to handle all of the *valid* combinations in many cases... also, the more
the shell tries to complete, the more easily it can be confused.
(e.g. git push 'v' git pull, "git p<tab>" is no longer enough, and
even "git pu<tab>" needs extra correction - and once you've typed "pus"
or "pul" completion doesn't help you any more either - it's still one
more key-stroke)

As is so often the case, you can try for perfect, or you can be happy
with 'good enough' or even 'works for me' :-)

In this case, grep through your history and see which commands and options you
use a lot and focus on them.

I've been using some custom tcsh completions and scripts to help
improve my git command line experience for a few years now, 
(but not pkg etc.). Rather than just waving my hands in the air, I've pulled
them together and put them up on github for your perusal.
If you're interested, you can find them at https://github.com/cobber/git-tools

Perhaps there's some ideas in there to help you put together something for pkg.

Cheers,

Steve


More information about the freebsd-questions mailing list