export REMOTEHOST=`echo $SSH_CLIENT | cut -d ' ' -f 1`
export HOSTIP=`echo $SSH_CONNECTION | cut -d ' ' -f 3`
function bbedit {
# bbedit won't open a remote file via sftp if it doesn't exist. So, if it's a new file
# create it, call bbedit to open, and then kill it.
FCREATED=0
if [ ! -e "$PWD/$1" ]
then
touch "$PWD/$1"
FCREATED=1
fi
ssh derosier@$REMOTEHOST /usr/local/bin/bbedit -c -u --front-window "sftp://$USER@$HOSTIP/$PWD/$1"
# The above call will background and return immediately. The file will open in bbedit
# but since we've created it, and we don't want to leave it around, we kill it right away.
# If the user saves it, it gets recreated and content is saved. If not, there's no file,
# so we're cool too. It's a bit odd, but it works.
if [ "$FCREATED" -eq "1" ]
then
rm "$PWD/$1"
fi
}
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/87C1D38D-8CAA-4EEA-8FF4-CF9E7CFF0D5E%40me.com.