diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-06-01 11:56:35 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-06-01 12:22:01 -0700 |
commit | 023b7528290e5fb57b4e6c53b54f60f3551f4672 (patch) | |
tree | 87d431137bed5ca0dea31798cbf1d329bde2308b /.shenv | |
parent | dea594ee0e3d71d99388516bf8aecc7364dc76f8 (diff) | |
download | dotfiles-023b7528290e5fb57b4e6c53b54f60f3551f4672.tar.gz |
have a constant fallback from GNU Emacs to plain vi
Diffstat (limited to '.shenv')
-rwxr-xr-x | .shenv | 38 |
1 files changed, 14 insertions, 24 deletions
@@ -9,38 +9,28 @@ set +e # ---- choose editor depending on what's available if [ "$DESKTOP_SESSION" = "i3" ]; then - ec_args="-c" + ec="emacsclient -c" else - ec_args="-t" + ec="emacsclient -t" fi +# Either GNU Emacs, or UNIX vi -- lightweight Emacs alternatives like +# mg and zile are so rarely installed, so let's have a constant +# fallback which is almost certainly available and which I can use +# well enough. When GNU Emacs is available, set ALTERNATE_EDITOR to +# the empty string so that an `emacs --daemon` process is spawned emacsclient=$(which emacsclient 2>/dev/null) -mg=$(which mg 2>/dev/null) -# best case: emacsclient and mg available -if [ -x "$emacsclient" -a -x "$mg" ]; then - EDITOR="emacsclient $ec_args" - ALTERNATE_EDITOR="mg" +if [ -x "$emacsclient" ]; then + EDITOR="$ec" + ALTERNATE_EDITOR="" + export ALTERNATE_EDITOR else - # only emacsclient, so change alternate editor - if [ -x "$emacsclient" ]; then - EDITOR="emacsclient $ec_args" - ALTERNATE_EDITOR="vi" - else - # no emacsclient, so see if we can fall back to mg - if [ -x "$mg" ]; then - EDITOR="mg" - ALTERNATE_EDITOR="vi" - # worse case: assume vi is available - else - EDITOR="vi" - fi - fi + EDITOR="vi" fi -unset ec_args +unset ec unset emacsclient -unset mg export EDITOR -VISUAL=$EDITOR +VISUAL="$EDITOR" export VISUAL # ---- set $PATH |