tcsh completions for svn URLs

For quite some time, I’ve wanted tcsh completions for URLs when using svn (the Subversion command-line client). I finally wrote my own recently.

There were solutions available on the web, but they only worked with file:// URLs. I suspect most developers are rarely using file:// URLs. Typically the repository is on another machine with some type of remote access. In my case, via svn+ssh:// URLs. I was unable to find anything that worked with remote URLs.

Since tcsh 6.17 and above expose a COMMAND_LINE environment variable that contains the current command line, it wasn’t rocket science to write a simple C++ program to complete svn URLs. The source code for my simple solution is available here: svnutils_tcsh.tgz

If you compile this and put the resulting cmpl_svn_url binary in your bin directory, you can then have an svn completion in your .tcshrc that contains this:

complete svn ...
             'C@file:///@`'"${HOME}/bin/cmpl_svn_url"'`@@' \
             'C@svn+ssh://@`'"${HOME}/bin/cmpl_svn_url"'`@@' \
             'C@http://@`'"${HOME}/bin/cmpl_svn_url"'`@@' \
             'C@https://@`'"${HOME}/bin/cmpl_svn_url"'`@@' \
             ...

Obviously this will be slow if access to the Subversion server is slow. That’s not the case for my home repository since it’s on a local gigabit ethernet connection. But even when slow, it’s handy for new checkouts, creating branches or tags, listing the repository or ‘svn cat’ to see a file in the repository.

Leave a Reply