BBEdit and Subversion: the Fruit Roll-up Post
I use vi daily, but much prefer BBEdit. The way I integrate them has evolved over time (see previous posts here, Useful subversion shell aliases, and BBEdit Gems (which appears to be down right now). In particular, I no longer configure BBEdit directly in ~/.subversion/config.
The new improved integration uses BBEdit whenever it’s available (I’m in front of the Mac), and falls back to the default (vi) when I’m connected via ssh.
First, I created ~/bin/edit.sh to hand off to BBEdit. I use edit.sh whenever BBEdit is appropriate:
#!/bin/sh # Edit in BBEdit, for programs that don't support arguments in $EDITOR. bbedit --wait --resume "$@"
Next, I configured my bash profile to prefer edit.sh when I’m not connected via ssh (which means when I am in front of the Mac or using ARD/VNC), as my EDITOR and PAGER. My profile doesn’t automatically determine whether to use bbdiff for Subversion, because I sometimes find it necessary to use non-BBEdit diff for Subversion (there are cases where the svn-to-bbedit handoff doesn’t work well, and I have ended up editing scratch files instead of the real files, for instance). Here’s the snippet that does this, from my profile:
if [[ ! $SSH_TTY ]]
then
if [ -x ~/bin/edit.sh ]
then
export EDITOR=~/bin/edit.sh
else export EDITOR=vi
fi
if [ -x /usr/bin/bbedit ]
then export PAGER="col -b | bbedit --clean --view-top"
fi
else export EDITOR=vi
fi # [[ ! $SSH_TTY ]]
In addition, I set up aliases for reviewing output from the svn command, based on Bob’s suggestions. I just copy and paste one or more lines from svn output to review changes in BBEdit:
alias A='bbedit --wait' alias AM='bbedit --wait' alias C='bbedit --wait' alias D='true' alias G='svn diff --diff-cmd bbdiff --extensions "--resume --wait"' alias I='true' alias M='svn diff --diff-cmd bbdiff --extensions "--resume --wait"' alias R='svn diff --diff-cmd bbdiff --extensions "--resume --wait"' alias U='bbedit --wait'
I update and then review status so often that I built my own TLA:
alias sus='svn update && svn status'
The following two commands provide “Subversion diff, with BBEdit” and “Subversion diff, no BBEdit”:
alias sdbb='svn diff --diff-cmd bbdiff --extensions "--resume --wait"' alias sdnb='svn diff --diff-cmd diff -x -u'
When I’m way behind and have a lot of changes to review, I use a one-off command to review all the changes since I fell out of step. I also scan the email log messages, but this catches all the changes, skipping intermediate versions which have already been replaced and consolidating multiple edits to the same file. The command is something like:
svn diff --diff-cmd bbdiff --extensions "--resume --wait" -r1039
PS-I get the Subversion client with “fink install svn-client-ssl“.
