You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Josh Glover <jo...@tfcci.com> on 2004/07/27 16:47:55 UTC

Patch for bash-completion that enables Subversion completion

Some of you, I suspect, might already be using bash-completion. If not,
you might find it worth your time to check out:

http://www.caliban.org/bash/
http://www.jmglov.net/unix/bash.html

bash-completion has pretty advanced completion for CVS, and I *really*
missed it when I switched to SVN a couple of weeks ago.

I found contrib/subversion in the source tarball for latest version of
bash-completion,[1] but I wanted something a little smarter, like how
completion for cvs(1) works currently.

So, I rolled my own. But, in the spirit of Master Foo (right, Matthew?),
and The Unix Way, I wrote a little Perl script that generates shell code
to implement completion, using the 'svn help' command. This has the nice
property of allowing me to automatically generate the code whenever svn
options or subcommands change. I have attached the Perl script as well,
just in case you are interested.

Find attached a patch against bash-completion-20040711 that implements
completion for svn(1) (Subversion).

I have submitted the patch to Ian, who wrote and maintains bash-
completion, so hopefully, it will be rolled into the main distribution
soon. Until then, you should always be able to grab the latest version
of the patch from:

http://opensource.jmglov.net/

(I know, it is not there yet, but it will be when I go home for lunch.)

Cheers,
Josh


[1] http://www.caliban.org/files/bash/bash-completion-20040711.tar.gz

-- 
Josh Glover <jo...@tfcci.com>

Software Engineer
Twenty First Century Communications, Inc.
http://www.tfcci.com/

GPG keyID 0x22111305 (E210 61C6 14DF B480 C211  AE2A 0F12 1D7B 2211 1305)
gpg --keyserver pgp.mit.edu --recv-keys 22111305

Re: Patch for bash-completion that enables Subversion completion

Posted by Josh Glover <jo...@tfcci.com>.
Quoth Josh Glover (Tue 2004-07-27 12:47:55PM -0400):

> Find attached a patch against bash-completion-20040711 that implements
> completion for svn(1) (Subversion).

And of course, in the spirit of Unending Stupidity, I forgot to actually
*attach* the files.

Here they are.

Sheepishly yours,
Josh

-- 
Josh Glover <jo...@tfcci.com>

Software Engineer
Twenty First Century Communications, Inc.
http://www.tfcci.com/

GPG keyID 0x22111305 (E210 61C6 14DF B480 C211  AE2A 0F12 1D7B 2211 1305)
gpg --keyserver pgp.mit.edu --recv-keys 22111305

Re: Patch for bash-completion that enables Subversion completion

Posted by Josh Glover <jo...@tfcci.com>.
Quoth Jacob Atzen (Tue 2004-07-27 10:19:12PM +0200):

> On Tue, Jul 27, 2004 at 12:47:55PM -0400, Josh Glover wrote:
>
> > bash-completion has pretty advanced completion for CVS, and I *really*
> > missed it when I switched to SVN a couple of weeks ago.
> 
> Could you please highlight the features you've built?

Sure. So far, all it does is complete a few "global" options to the svn
command itself, (actually, I just noticed from looking at the SVN book,
*all* options are global, so I had better fix that!) all subcommands,
and, for each subcommand, all valid options, according to
'svn help <subcommand>'.

> One really nifty thing I found was that when doing "svn add [tab]" it
> will only list files not yet under version control unless there's no
> such files.

This is a planned feature.

> Unfortunately the same doesn't seem to apply to the svn remove or diff
> commands. And it get's real bad with svn rename which won't tabcomplete
> filenames at all.

Yes, this is a nasty side-effect of bad completion code, when you lose the
minimal completion that the shell already offers. :(

As for planned features, here is the list:

- Complete only files (and directories) *not* already under Subversion
  control for:
 - add
 - import
- Complete only files (and directories) already under Subversion control
  for all other subcommands with a PATH or TARGET argument (except status,
  since you might want to know that a certain file *is not* under SVN
  control)
- Remote repository completion for all subcommands that have a URL or
  TARGET argument, e.g. blame, cat, checkout, etc
- Appropriate completion for switches
- Complete subcommands for help
- Completion for svnadmin and svnlook

I will use the Debian code (thanks, everyone who forwarded that to me)
as a reference, but I like the version-portability property of my code
generator so much that I think I will stick with it.

Any and all feedback is welcome.

Cheers,
Josh

-- 
Josh Glover <jo...@tfcci.com>

Software Engineer
Twenty First Century Communications, Inc.
http://www.tfcci.com/

GPG keyID 0x22111305 (E210 61C6 14DF B480 C211  AE2A 0F12 1D7B 2211 1305)
gpg --keyserver pgp.mit.edu --recv-keys 22111305

Re: Patch for bash-completion that enables Subversion completion

Posted by Jacob Atzen <ja...@aub.dk>.
On Tue, Jul 27, 2004 at 12:47:55PM -0400, Josh Glover wrote:
> bash-completion has pretty advanced completion for CVS, and I *really*
> missed it when I switched to SVN a couple of weeks ago.

Could you please highlight the features you've built? I'm a zsh user
myself but would love the inspiration. zsh comes with builtin svn
support and support tabcompletion of both subcommands and parameters.
One really nifty thing I found was that when doing "svn add [tab]" it
will only list files not yet under version control unless there's no
such files. Unfortunately the same doesn't seem to apply to the svn
remove or diff commands. And it get's real bad with svn rename which
won't tabcomplete filenames at all.

Please understand that I'm not trying to make this into a
my-shell-is-better-than-your-shell debacle. I'm simply hoping we might
inspire eachother.

-- 
Cheers,
- Jacob Atzen


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Patch for bash-completion that enables Subversion completion

Posted by kf...@collab.net.
Josh Glover <jo...@tfcci.com> writes:
> Do you have any idea how that file is generated? If it is programmatically
> generated, I would like to abandon my work and hack on the code generator.
> Otherwise, I think I will stand by my decision to work on making my code
> generator do what I want.

I believe Philip Martin has been maintaining it by hand.

> I will be happy to contribute my work to the Subversion project, so if you
> chaps want it, let me know.

We probably do; maybe Philip can say if and how the two should be
integrated.  I don't think he reads this list, so you should post
patches to dev@subversion.tigris.org.

-Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Patch for bash-completion that enables Subversion completion

Posted by Josh Glover <jo...@tfcci.com>.
Quoth kfogel@collab.net (Wed 2004-07-28 11:53:20AM -0500):

> Josh, were you aware of the file
> 
>    tools/client-side/bash_completion
> 
> in the Subversion source tree?  In the repository, that's
> 
>    http://svn.collab.net/repos/svn/trunk/tools/client-side/bash_completion

Nope. That answers the question about where the Debian bash-completion.d
file comes from. :)

Do you have any idea how that file is generated? If it is programmatically
generated, I would like to abandon my work and hack on the code generator.
Otherwise, I think I will stand by my decision to work on making my code
generator do what I want.

I will be happy to contribute my work to the Subversion project, so if you
chaps want it, let me know.

Cheers,
Josh

-- 
Josh Glover <jo...@tfcci.com>

Software Engineer
Twenty First Century Communications, Inc.
http://www.tfcci.com/

GPG keyID 0x22111305 (E210 61C6 14DF B480 C211  AE2A 0F12 1D7B 2211 1305)
gpg --keyserver pgp.mit.edu --recv-keys 22111305

Re: Patch for bash-completion that enables Subversion completion

Posted by kf...@collab.net.
Josh, were you aware of the file

   tools/client-side/bash_completion

in the Subversion source tree?  In the repository, that's

   http://svn.collab.net/repos/svn/trunk/tools/client-side/bash_completion

Best,
-Karl Fogel

Josh Glover <jo...@tfcci.com> writes:
> Some of you, I suspect, might already be using bash-completion. If not,
> you might find it worth your time to check out:
> 
> http://www.caliban.org/bash/
> http://www.jmglov.net/unix/bash.html
> 
> bash-completion has pretty advanced completion for CVS, and I *really*
> missed it when I switched to SVN a couple of weeks ago.
> 
> I found contrib/subversion in the source tarball for latest version of
> bash-completion,[1] but I wanted something a little smarter, like how
> completion for cvs(1) works currently.
> 
> So, I rolled my own. But, in the spirit of Master Foo (right, Matthew?),
> and The Unix Way, I wrote a little Perl script that generates shell code
> to implement completion, using the 'svn help' command. This has the nice
> property of allowing me to automatically generate the code whenever svn
> options or subcommands change. I have attached the Perl script as well,
> just in case you are interested.
> 
> Find attached a patch against bash-completion-20040711 that implements
> completion for svn(1) (Subversion).
> 
> I have submitted the patch to Ian, who wrote and maintains bash-
> completion, so hopefully, it will be rolled into the main distribution
> soon. Until then, you should always be able to grab the latest version
> of the patch from:
> 
> http://opensource.jmglov.net/
> 
> (I know, it is not there yet, but it will be when I go home for lunch.)
> 
> Cheers,
> Josh
> 
> 
> [1] http://www.caliban.org/files/bash/bash-completion-20040711.tar.gz
> 
> -- 
> Josh Glover <jo...@tfcci.com>
> 
> Software Engineer
> Twenty First Century Communications, Inc.
> http://www.tfcci.com/
> 
> GPG keyID 0x22111305 (E210 61C6 14DF B480 C211  AE2A 0F12 1D7B 2211 1305)
> gpg --keyserver pgp.mit.edu --recv-keys 22111305

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org