diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-01-18 17:17:33 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-01-18 17:17:33 +1300 |
commit | ffd9d95b6adf5982448e1685a8c79c74b148cb00 (patch) | |
tree | 5b9f8edafb5dda1aa9751291597809344357421d /sh/shrc.d | |
parent | Remove executable bit from source script (diff) | |
download | dotfiles-ffd9d95b6adf5982448e1685a8c79c74b148cb00.tar.gz dotfiles-ffd9d95b6adf5982448e1685a8c79c74b148cb00.zip |
Color ed(1) prompt if possible
Diffstat (limited to 'sh/shrc.d')
-rw-r--r-- | sh/shrc.d/ed.sh | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/sh/shrc.d/ed.sh b/sh/shrc.d/ed.sh index d7d3fa2f..3e544c74 100644 --- a/sh/shrc.d/ed.sh +++ b/sh/shrc.d/ed.sh @@ -11,8 +11,20 @@ ed() { [ -e "$HOME"/.cache/ed/verbose ] && set -- --verbose "$@" - # Add an asterisk prompt (POSIX feature) - set -- -p\* "$@" + # Add an asterisk prompt (POSIX feature); color it dark green if we can + set -- -p "$( + if [ "$(tput colors || tput Co)" -gt 8 ] ; then + ec=${ED_PROMPT_COLOR:-2} + tput setaf "$ec" || + tput setaf "$ec" 0 0 || + tput AF "$ec" || + tput AF "$ec" 0 0 + printf %s "${ED_PROMPT:-'*'}" + tput sgr0 || tput me + else + printf %s "${ED_PROMPT:-'*'}" + fi 2>/dev/null + )" "$@" # Run in rlwrap(1) if available set -- ed "$@" |