diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-03-24 15:34:56 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-03-24 15:34:56 +1300 |
commit | d2d66ee13c568c5fced6033f69929ad172b01281 (patch) | |
tree | d7c2288739d9cbfb87df5b4b2dfebe1a41706533 | |
parent | Merge branch 'master' into port/bsd/freebsd (diff) | |
parent | Add a semicolon to appease old sed(1) (diff) | |
download | dotfiles-d2d66ee13c568c5fced6033f69929ad172b01281.tar.gz dotfiles-d2d66ee13c568c5fced6033f69929ad172b01281.zip |
Merge branch 'master' into port/bsd/freebsd
-rw-r--r-- | README.markdown | 1 | ||||
-rwxr-xr-x | bin/exm | 11 | ||||
-rw-r--r-- | man/man1/exm.1df | 19 | ||||
-rw-r--r-- | sh/profile.d/editor.sh | 11 | ||||
-rw-r--r-- | sh/shrc.d/path.sh | 8 |
5 files changed, 41 insertions, 9 deletions
diff --git a/README.markdown b/README.markdown index 4cd4820c..8b95e1a9 100644 --- a/README.markdown +++ b/README.markdown @@ -469,6 +469,7 @@ Installed by the `install-bin` target: any options, mostly useful for scripts. * `eds(1df)` edits executable script files in `EDSPATH`, defaulting to `~/.local/bin`, for personal scripting snippets. +* `exm(1df)` works around a screen-clearing quirk of Vim's `ex` mode. * `finc(1df)` counts the number of results returned from a set of given `find(1)` conditions. * `fnl(1df)` runs a command and saves its output and error into temporary diff --git a/bin/exm b/bin/exm new file mode 100755 index 00000000..3850f118 --- /dev/null +++ b/bin/exm @@ -0,0 +1,11 @@ +#!/bin/sh +# Prevent Vim's ex(1) implementation from clearing the screen +if [ -t 0 ] ; then + ver=$(ex --version | sed '1{s/ .*//;q;}') 2>/dev/null + case $ver in + # Lie to Vim; tell it it's a dumb terminal, and that its required "cm" + # feature is invoked with a newline character. + VIM) set -- -T dumb --cmd 'exe "set t_cm=\<C-M>"' "$@" ;; + esac +fi +exec ex "$@" diff --git a/man/man1/exm.1df b/man/man1/exm.1df new file mode 100644 index 00000000..7a68a031 --- /dev/null +++ b/man/man1/exm.1df @@ -0,0 +1,19 @@ +.TH EXM 1df "March 2017" "Manual page for exm" +.SH NAME +.B exm +\- invoke Vim's ex(1) with a dumb terminal +.SH SYNOPSIS +.B exm +[EX_OPTIONS...] [FILES] +.SH DESCRIPTION +.B exm +works around a quirk of Vim that causes it to clear the screen when invoked as +ex(1) interactively. It applies Vim's -T option to force the terminal to the +builtin "dumb" terminal. +.SH CAVEATS +This breaks switching to visual mode with :visual completely, as the terminal +will persist in its dumb state. I'm not sure there's a way to fix this. If +there were a Vim :autocmd for mode switching, it might be possible, or perhaps +by wrapping :visual somehow to :set terminal=$TERM before the switch. +.SH AUTHOR +Tom Ryder <tom@sanctum.geek.nz> diff --git a/sh/profile.d/editor.sh b/sh/profile.d/editor.sh index 5d6b249e..307879fe 100644 --- a/sh/profile.d/editor.sh +++ b/sh/profile.d/editor.sh @@ -1,7 +1,16 @@ -# Set command-line editor; ed if we've got it (!), but ex will do fine +# Ideally, we'd use plain old ed(1), but many Linux distributions don't install +# it by default if command -v ed >/dev/null 2>&1 ; then EDITOR=ed + +# Failing that, if we have both vim(1) and exm(1df) in our $PATH, use the +# latter to work around Vim's ex mode screen-clearing +elif { command -v vim && command -v exm ; } >/dev/null 2>&1 ; then + EDITOR=exm + +# Otherwise, just call ex(1) directly else EDITOR=ex fi + export EDITOR diff --git a/sh/shrc.d/path.sh b/sh/shrc.d/path.sh index 2759e11f..79b48fd5 100644 --- a/sh/shrc.d/path.sh +++ b/sh/shrc.d/path.sh @@ -1,14 +1,6 @@ # Function to manage contents of PATH variable within the current shell path() { - # The second argument, the directory, can never have a colon - case $2 in - *:*) - printf >&2 'path(): %s illegal colon\n' "$2" - return 2 - ;; - esac - # Check first argument to figure out operation case $1 in |