dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | Submodules | README

commit 340921a4e7ee8e3affacf16c9ead094d7273bcfb (patch)
parent d230030e8afbaf2568684b7f65b404975227b37d
Author: Alex Karle <alex@alexkarle.com>
Date:   Wed, 25 Aug 2021 00:17:33 -0400

bin: Add depth level to e(1) prompt

With the advent of t(1) to tag jump in ed(1) (or e(1), my wrapper),
it's handy to know just how deep in the ed(1) stack we are!

This also comes up when shelling out to ed(1) via git-commit within
ed(1).

Diffstat:
Mbin/e | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/bin/e b/bin/e @@ -2,10 +2,19 @@ # e -- slightly improved ed(1) wrapper set -e +# If we're already in e, export a count to show the depth! +if [ -z "$E_LVL" ]; then + PROMPT="> " + export E_LVL=0 +else + export E_LVL=$((${E_LVL} + 1)) + PROMPT="${E_LVL}> " +fi + # short circuit fallback to ed(1) if no rlwrap present if ! command -v rlwrap >/dev/null; then echo "warning: rlwrap not found, falling back to regular ed" 1>&2 - exec ed -p'> ' "$@" + exec ed -p"$PROMPT" "$@" fi for f in .tags tags; do @@ -32,4 +41,4 @@ exec rlwrap \ --complete-filenames \ --histsize 10000 $COMP \ --extra-char-after-completion '' \ - ed $VERBOSE -p"> " "$@" + ed $VERBOSE -p"$PROMPT" "$@"