diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-16 11:01:51 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-16 11:01:51 +1300 |
commit | 49a86169a583de6d6b934962e67f91653485e155 (patch) | |
tree | 5d37967a4520657afd39858cfb85135f627e530e | |
parent | Script for choosing random background on startup (diff) | |
download | dotfiles-49a86169a583de6d6b934962e67f91653485e155.tar.gz dotfiles-49a86169a583de6d6b934962e67f91653485e155.zip |
Refactor ed() wrapper, add rlwrap(1)
-rw-r--r-- | bash/bashrc.d/ed.bash | 29 | ||||
-rw-r--r-- | vim/after/syntax/mail.vim | 11 |
2 files changed, 33 insertions, 7 deletions
diff --git a/bash/bashrc.d/ed.bash b/bash/bashrc.d/ed.bash index 5a54c761..faee7205 100644 --- a/bash/bashrc.d/ed.bash +++ b/bash/bashrc.d/ed.bash @@ -1,15 +1,30 @@ # Add a colon prompt to ed when a command is expected rather than text; makes # it feel a lot more like using ex. Only do this when stdin is a terminal, -# however. Also try and use -v for more verbose error output. +# however. Also try and use -v for more verbose error output, and rlwrap(1) if +# it's available. ed() { + + # Options for ed(1), and a command string in which to wrap the call if + # appropriate + local -a opts wrap + if [[ -t 0 ]] ; then - if ed -sv - </dev/null >/dev/null 2>&1 ; then - command ed -vp: "$@" - else - command ed -p: "$@" + + # Assemble options for interactive use: colon prompt, and verbose if + # available (-p is POSIX, but -v is not) + opts=(-p :) + if ed -sv - </dev/null >&0 2>&0 ; then + opts[${#opts[@]}]=-v + fi + + # Use rlwrap(1) if it's available, but don't throw a fit if it isn't + if hash rlwrap 2>/dev/null ; then + wrap=(rlwrap) fi - else - command ed "$@" fi + + # Execute the ed(1) call, in a wrapper if appropriate and with the + # concluded options + command "${wrap[@]}" ed "${opts[@]}" "$@" } diff --git a/vim/after/syntax/mail.vim b/vim/after/syntax/mail.vim new file mode 100644 index 00000000..575b3a28 --- /dev/null +++ b/vim/after/syntax/mail.vim @@ -0,0 +1,11 @@ +" mail.vim's quoting rules are overcomplicated and get too much wrong, just +" turn them off +syn region mailQuoted keepend contains=mailVerbatim,mailHeader,@mailLinks,mailSignature,@NoSpell start="^\z([a-z]\+>[]|}>]\)" end="^\z1\@!" fold +highlight link mailQuoted Comment +highlight! link mailQuoted1 NONE +highlight! link mailQuoted2 NONE +highlight! link mailQuoted3 NONE +highlight! link mailQuoted4 NONE +highlight! link mailQuoted5 NONE +highlight! link mailQuoted6 NONE + |