A friend tossed me a handful of aliases that, once plopped into your shells initialization scripts, make dealing with Subversion all that much more pleasant. It was one of those “Oh, jeez, that is so stupid obvious… why didn’t I think of that” moments.
Drop the aliases into wherever your shell sets up aliases (
~/bashrc or something like it, typically). The syntax may be different.
alias M 'svn diff \!* | mate' alias G 'svn diff \!* | mate' alias U 'svn diff \!* | mate' alias R 'svn diff' alias C 'see' alias A 'true' alias D 'true' alias I 'true'
Once in place, you can now triple-click-copy-paste any line in the subversion output to see more detailed information.
Update: I updated the
U aliases to both use TextMate and to work fine with multiple arguments (just because it seemed like an appropriately big stick to bring to the party).
For example, an ‘svn status’ on my PyObjC work area outputs the following:
[pyobjc/trunk/pyobjc] bbum% svn status M Lib/AppKit/test/test_nsopenpanel.py
I simply triple-click the
M Lib/AppKit/test/test_nsopenpanel.py and copy/paste/return. Subversion will then display the differences between what is in my workarea and what is currently in the repository.
The third command will cause the conflicted file to open in SubEthaEdit. Change it to
mate for TextMate or
bbedit for BBEdit.
~/.subversion/config, I have:
diff-cmd = /Volumes/Data/Users/bbum/bin/svndiffshim.py
If you don’t want to use FileMerge (or
bbdiff), change the two
svn diff aliases to
clear && svn diff. This will cause the Terminal window to be cleared prior to displaying the output.
– Michael McCracken reminded me that I really ought to go look at my application menus a bit more often. Terminal includes
Paste Selection (and
Paste Escaped Text, another useful idiom I forgot about). So, triple-click, then hit shift-cmd-V to paste the selected line. One less keystroke!
– Dominik Wagner mentions that he uses
svn diff | see -m diff to cause the diff to be opened and nicely colorized in SubEthaEdit. Very nice.
As an improvement in the above context, I aliased it to
svn diff \!* | see -m diff as that fixes two problems. First, it only diffs the file copy/pasted. Secondly, it doesn’t also open the file(s).
Of course, all of this now means that M is an super-tiny abbreviation for Diff This Stuff Now.
– Wilfredo Sánchez Vega added the
true aliases as seen above. It allows you to copy/paste in a large chunk of the output without having to worry about silly syntax errors. Of course, there are still a number of edge cases — if the other columns are used or ‘?’ in the output — but this makes it much more generic.