view unixSoft/bin/magic_editor.sh @ 307:e37b00236907

zshrc: work around my shell function that turns on utf8 in screen The zsh built in which was getting confused by the function, and always claimed screen was installed. I'm finally running into machines with tmux but not screen, so I noticed.
author Augie Fackler <raf@durin42.com>
date Sat, 19 Jan 2013 19:29:58 -0600
parents c30d68fbd368
children
line wrap: on
line source

#!/bin/sh
# "magically" pick the 'best' available editor for a given platform

# use emacs if it is running a server
# disabled because I ended up not liking using emacs as $EDITOR, weird, I know
# tempuid=`id -u`
# temphost=`hostname`
# if [ -e "/tmp/esrv$tempuid-$temphost" ]
# then
#     emacsclient "$@"
#     exit $?
# fi

# use subethaedit on OS X
if test "`uname`" = "Darwin" ; then
	if test "x`whereis see`" != "x" ; then
		see -w "$@"
		exit $?
	# no subetha, then try for textwrangler
	elif test "x`whereis edit`" != "x" ; then
		edit -w "$@"
		exit $?
	fi
fi

# we're not on a mac (or preferred mac editors failed, so we like gvim
if test "x`whereis gvim`" != "x"  && test "x$DISPLAY" != "x" ; then
	gvim -f "$@"
# ...or vim, since either gvim wasn't there or display wasn't set
elif test "x`whereis vim`" != "x" ; then
	vim -f "$@"
# wow, this is a weird host, use vi. if that doesn't exist, we're really screwed
else
	vi "$@"
fi

exit $?