+if [ -x /usr/bin/emacsclient ] && [ -x /usr/bin/emacs ]; then
+ # reset the tempdir to deal with setuid things clearing it
+ export TMPDIR="$(echo ~/tmp)";
+ # If TERM is set to dumb, reset it to linux. (emacs does this for
+ # some reason)
+ if [ "$TERM" = "dumb" ]; then
+ TERM="linux"
+ fi;
+ if [ -z "$DISPLAY" ]; then
+ exec emacsclient --alternate-editor /usr/bin/vi -c -nw "$@";
+ else
+ exec emacsclient --alternate-editor /usr/bin/vi -c "$@";
+ fi;
+fi;