On Jan 18, 2008 6:52 PM, Diggory Hardy <[EMAIL PROTECTED]> wrote:
> Maybe I should also send to the mailing list ;-)
>
> Well, I cannibalised your __fish_describe_command function into the following
> which gets most of the way there. But I don't really know awk so would you
> mind helping out a little to save me reading up on it?
> Two things; 1: long descriptions get shortened with trailing dots (although
> maybe you'd rather keep it this way)
> and 2: the 'git-' bit needs to be stripped off the beginning of the names.
>
> apropos git- | awk -v FS=" +- +" '{
> split($1, names, ", ");
> for (name in names)
> if (names[name] ~ /^'"$argv"'.* *\([18]\)/ ) {
> sub( "( |\t)*\\\([18]\\\)", "", names[name] );
> sub( " \\\[.*\\\]", "", names[name] );
> print "complete -c git -a " names[name] " -d \\"" $2 "\\"";
> }
> }'Hmm, I just realised I should have said something a lot sooner. I've been dabbling with machine generating completion files for some time with moderate sucess. The code for doing this is still pretty far from good enough to work in the general case, but I find it rather useful as a starting point. There are two separate files that I'm working on, and both are shipped in the fish tarball. First, there is make_vcs_completions.fish, which is a fish-style shellscript which generates the completions for darcs, mercurial, subversion and cvs. The file is rather full of special casing for minor differences, but because the above mentioned version control systems have help systems syntax, help system output format and command structure that are almost identical, it was possible to create a single script to generate decent completions for all those commands. If git behaves mostly like those other commands, it may be possible to make use of this script. Secondly, make_completions.py is a python script that tries to parse the manual page of a command into tab completions. The exact format of manual pages varies enough that the script only works properly for a rather small subset of all manual pages and the generated completions usually need a bit of massaging before they're fit for use, but it's still better than nothing. Sorry for not mentioning this sooner, hope you'll be able to make use of these scripts. Axel > > Thanks in advance. > Diggory > > On Friday 18 January 2008 16:00:47 you wrote: > > > On Jan 16, 2008 11:21 AM, Diggory Hardy <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > > > Here's a few git completions (probably only a very small set of available > > > git commands). But after adding them, I noticed that using tab-completion > > > on 'git-' (possible since git commands are also available using > > > hard-linked binaries 'git-*') not only lists all available commands, but > > > their descriptions too (not ones I added) --- where has fish got their > > > descriptions from? They're not in /usr/share/fish/completions or any > > > other completion dir. > > > > > > Not that it's particularly important, but I'm intrigued and it could > > > provide an easy way to add full tab-completion with descriptions. > > > > Fish calls an internal shellscript function called > > __fish_describe_command in order to find a description for a command. > > Actually, it finds descriptions for all commands beginning with a > > specified prefix, so if you call '__fish_describe_command git' you > > will get a list of descriptions for all git subcommands. > > > > What __fish_describe_command actually does is that it uses the apropos > > command to search the whatis database (which in turn is generated by > > from the manual pages installed in the system). Unfortunatly, the > > definition of the __fish_describe_command is a bit of an abomination, > > because the actual format of the apropos output varies significantly > > between platforms and even between Linux distributions. > > > > Hope that answers you question, and that you'll be sending us a patch > > containing lots of git tab completions soon! > > > > > > Axel > > > > > Diggory > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by: Microsoft > > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > _______________________________________________ > > > Fish-users mailing list > > > [email protected] > > > https://lists.sourceforge.net/lists/listinfo/fish-users > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Fish-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fish-users
