annotate unixSoft/bin/magic_editor.sh @ 377:117e3c11d953

zprofile: introduce zprofile use El Capitan (OS X 10.11) introduces a system-level /etc/zprofile which uses a path_helper thing to mangle $PATH. Unfortunately, the way path_helper works, it forces /usr/local/bin and /usr/bin to the *start* of the PATH variable, which means that any PATH mutations I want have to run after /etc/zprofile calls path_helper. As such, move my path insertions into .zprofile{,-machine} rather than .zshenv{,-machine} so that I can still ensure my path entries are at the start of PATH rather than the end. This works because: > Commands are then read from $ZDOTDIR/.zshenv. If the shell is a > login shell, commands are read from /etc/zprofile and then > $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands > are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the > shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read. This means that non-login shells no longer pick up my custom PATH entries, but as I only use OS X as a desktop OS that seems like a workable tradeoff for now.
author Augie Fackler <raf@durin42.com>
date Sun, 31 Jan 2016 20:46:29 -0500
parents c30d68fbd368
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 #!/bin/sh
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 # "magically" pick the 'best' available editor for a given platform
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 # use emacs if it is running a server
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 # disabled because I ended up not liking using emacs as $EDITOR, weird, I know
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 # tempuid=`id -u`
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 # temphost=`hostname`
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 # if [ -e "/tmp/esrv$tempuid-$temphost" ]
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 # then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 # emacsclient "$@"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 # exit $?
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 # fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 # use subethaedit on OS X
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 if test "`uname`" = "Darwin" ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 if test "x`whereis see`" != "x" ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 see -w "$@"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 exit $?
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 # no subetha, then try for textwrangler
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 elif test "x`whereis edit`" != "x" ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 edit -w "$@"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 exit $?
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 # we're not on a mac (or preferred mac editors failed, so we like gvim
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 if test "x`whereis gvim`" != "x" && test "x$DISPLAY" != "x" ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 gvim -f "$@"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 # ...or vim, since either gvim wasn't there or display wasn't set
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 elif test "x`whereis vim`" != "x" ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 vim -f "$@"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 # wow, this is a weird host, use vi. if that doesn't exist, we're really screwed
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 else
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 vi "$@"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 exit $?