Archive for May, 2006

BBEdit and Subversion

BBEdit and Subversion now play well together (actually it’s since BBEdit 8.1, but I hadn’t noticed at the time). I added a few lines to ~/.subversion/config:

[helpers]
diff-cmd = bbdiff
extensions = --wait --resume

Now “svn diff” (with or without arguments) does the right thing.

Update: svn honors $EDITOR.

Comments

ssh keychain vs. ssh Forwarding

I use Gentoo keychain heavily, to cache ssh private keys. If you use it on a few workstations, and make it a point of clearing keys or stopping keychain, you will find yourself in a situation where you ssh from a machine with keys into a machine without keys. For a while I was picking up the (useless) keychain on the remote machine I sshed into, instead of the loaded keychain on the local machine I sshed from. This .profile refinement doesn’t load keychain if it can find an active agent:

  if [[ `which keychain` ]]
  then
    if [[ ! ${SSH_CLIENT} ]]
    then
      keychain -q --noask; . ~/.keychain/`uname -n`-sh
    fi # [[ ! ${SSH_CLIENT} ]]

    alias  kc="keychain --timeout 540 ~/.ssh/id_dsa; . ~/.keychain/`uname -n`-sh"
  fi # [[ `which keychain` ]]

Update 2006/05: I recently switched from Gentoo keychain to SSHKeychain. It optionally integrates with the Apple Keychain (including automatic locking and loading of keys), and configures global environment variables for BBEdit and other co-operating tools.

http://sshkeychain.org/

Comments

Network Monitoring with ping

For long-term low-overhead network monitoring, I came up with the following (note that the ping arguments are for Mac OS X ping — Linux syntax is a bit different).

Put these into cron (with crontab -e):

0  0   *   *   *   ping -c 144 -Q -i60 www.speakeasy.net >> ~/public_html/dsl.log
*/10    *   *   *   *   date >> ~/public_html/dsl.log

And watch the status something like this: tail -f ~/public_html/dsl.log

Comments

Using bbedit as My EDITOR and PAGER

When I’m in front of the Mac, I want to use use BBEdit as my EDITOR and PAGER. When I’m connected via ssh from another computer, I need to fall back to vi and less. The following snippets handle this for me. The first one goes in a shell initialization file such as .profile or .bashrc, and the second one is a separate shell script.

if [[ ! $SSH_TTY ]]
 then
  if [ -x ~/bin/edit.sh ]
   then export EDITOR=~/bin/edit.sh
  fi
  if [ -x /usr/bin/bbedit ]
   then export PAGER="col -b | bbedit --clean --view-top"
  fi
fi # [[ ! $SSH_TTY ]]
pepper@pepperbook:~$ cat bin/edit.sh 
#!/bin/sh
# Edit in BBEdit, for programs that don't support arguments in $EDITOR.
bbedit --wait --resume "$@"

BBEdit’s command-line helper (bbedit), can invoke BBEdit, but normally returns immediately after passing along the specified file(s) — it doesn’t wait for the user to finish editing the file, as a standard UNIX editor would, so Bare Bones provides the -w option to make bbedit wait to return. Unfortunately, some programs won’t run a program with arguments as EDITOR, so it has to be embedded into a shell-script that adds --wait --resume internally.

The PAGER bit is similar, and inspired by a TidBITS-Talk thread.

Comments