Skip to content

Commit

Permalink
In screen/tmux locally, use non-graphical EDITOR/VISUAL.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnichol committed Oct 31, 2011
1 parent 388d233 commit 03c3439
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -1127,26 +1127,36 @@ cdf() {

# Set the default editor
if [ -z "$SSH_CLIENT" ] ; then # for local/console sessions
if command -v mvim >/dev/null ; then
case "$TERM_PROGRAM" in
Apple_Terminal) _terminal="Terminal" ;;
iTerm.app) _terminal="iTerm" ;;
esac
export EDITOR="mvim -f -c \"au VimLeave * !open -a ${_terminal}\""
export BUNDLER_EDITOR="mvim"
unset _terminal
elif command -v gvim >/dev/null ; then
export EDITOR="gvim -f"
export BUNDLER_EDITOR="gvim"
elif command -v mate >/dev/null ; then
export EDITOR="mate -w"
export EDITOR="mate"
elif command -v vim >/dev/null ; then
export EDITOR="vim"
export BUNDLER_EDITOR="$EDITOR"
else
export EDITOR="vi"
export BUNDLER_EDITOR="$EDITOR"
if [[ "$TERM" == screen* ]] ; then # we're in screen or tmux
if command -v vim >/dev/null ; then
export EDITOR="vim"
export BUNDLER_EDITOR="$EDITOR"
else
export EDITOR="vi"
export BUNDLER_EDITOR="$EDITOR"
fi
else # we're on a normal term console
if command -v mvim >/dev/null ; then
case "$TERM_PROGRAM" in
Apple_Terminal) _terminal="Terminal" ;;
iTerm.app) _terminal="iTerm" ;;
esac
export EDITOR="mvim -f -c \"au VimLeave * !open -a ${_terminal}\""
export BUNDLER_EDITOR="mvim"
unset _terminal
elif command -v gvim >/dev/null ; then
export EDITOR="gvim -f"
export BUNDLER_EDITOR="gvim"
elif command -v mate >/dev/null ; then
export EDITOR="mate -w"
export EDITOR="mate"
elif command -v vim >/dev/null ; then
export EDITOR="vim"
export BUNDLER_EDITOR="$EDITOR"
else
export EDITOR="vi"
export BUNDLER_EDITOR="$EDITOR"
fi
fi
else # for remote/ssh sessions
if command -v vim >/dev/null ; then
Expand Down

0 comments on commit 03c3439

Please sign in to comment.