Am I connected remotely?

I now share my dotfiles between the various OS X machines I use daily, using Dropbox and symlinks.

However, I have many aliases and functions that need to act differently if I only have a console session at the machine in question, or a full GUI session.

With bash, this is easy to test:

1 export EDITOR='nano'
2 if [[ -z "$SSH_CONNECTION" && $OSTYPE =~ ^darwin ]]; then
3 export EDITOR='mate --wait'
4 export TEXEDIT='mate -w -l %d "%s"'
5 export LESSEDIT='mate -l %lm %f'
6 fi

Now, if I am remotely connected to a machine, then I will get nano as my editor, but if I am sitting directly in front of it, then it will open Textmate.