]> git.donarmstrong.com Git - bin.git/blob - sane_editor
* fix -n/-z test of sane editor
[bin.git] / sane_editor
1 #!/bin/sh
2
3 # Order of preference
4 # gnuclient
5 # jed
6 # juno
7 # vi
8 # nano
9 # ed
10
11 # modify the gsrvdir check to search for directories that are owned by me
12 if [ -x /usr/bin/emacsclient ] && [ -x /usr/bin/emacs ]; then
13     # reset the tempdir to deal with setuid things clearing it
14     export TMPDIR="$(echo ~/tmp)";
15     if ( emacsclient -n -e '()' </dev/null >/dev/null); then
16         if [ -z "$DISPLAY" ]; then
17             exec emacsclient -c -nw "$@";
18         else
19             exec emacsclient -c "$@";
20         fi;
21     fi;
22 fi;
23 if [ -x /usr/bin/gnuclient ] && [ -x /usr/bin/emacs ]; then
24     if ( gnuclient -batch < /dev/null >/dev/null); then
25         exec gnuclient "$@";
26     fi;
27 fi;
28 if [ -x /usr/bin/vi ]; then
29     exec vi "$@";
30 fi;
31 if [ -x /usr/bin/nano ]; then 
32     exec nano "$@";
33 fi;
34 if [ -x /usr/bin/ed ]; then
35     exec ed "$@";
36 fi;
37 echo "Unable to find a suitable editor" >/dev/stderr;
38 exit 1;