if [[ ! "$SSH_TTY" && "$OSTYPE" =~ ^darwin ]]; then
  export EDITOR='subl -w'
  export LESSEDIT='subl %f'
else
  export EDITOR=$(type emacs nano pico 2>/dev/null | sed 's/ .*$//;q')
fi

export VISUAL="$EDITOR"

if [[ ! "$SSH_TTY" ]] && which subl >/dev/null 2>&1; then
  export EDITOR='subl -w'
  export LESSEDIT='subl %f'
else
  export EDITOR=$(type emacs nano pico 2>/dev/null | sed 's/ .*$//;q')
fi

export VISUAL="$EDITOR"

Set editor to use sublime if it is available, even on linux.
Set editor to use sublime if it is available, even on linux.
