I often use the BBEdit command line tool to quickly open and edit local files from the command line. In fact, I use it so much that I would find myself trying to use it while logged into remote machines via SSH:
[ben@remoteServer123 ~]$ bbedit MyLargePythonScript.py
bbedit: Command not found.
If I wanted to use BBEdit, I would have to use its clunky (IMHO) SFTP/FTP interface to navigate to the file and open it. Finally, I got around to putting together a simple alias that will tell your local copy of BBEdit to open the remote file via sftp. Simpy add this alias to your .cshrc file (or equivalent) on the remote host:
alias bbedit 'ssh ben@$REMOTEHOST bbedit "sftp://$USER@$HOST/$PWD/!:1"'
Unless your name is Ben, you'll have to replace ben with your own user name on your local Mac, of course, but otherwise it works on the various flavors of unix I log into remotely. And of course, you have to have Remote Login enabled in the Sharing panel of System Preferences.
Now when I try to open that file:
[ben@remoteServer123 ~]$ bbedit MyLargePythonScript.py
ben@localMacHostName's password:
I enter my password, and then after a second or two, BBEdit opens displaying my file. If you have a bookmark set up for the remote host in BBEdit, BBEdit won't even ask for a password.
set SSH_CLIENT_ADDRESS = `echo $SSH_CONNECTION | cut -f1 -d" "`
set SSH_HOST_ADDRESS = `echo $SSH_CONNECTION | cut -f3 -d" "`
[robg adds: I haven't tested this one...]
Mac OS X Hints
http://hints.macworld.com/article.php?story=20050809160807834