From 340921a4e7ee8e3affacf16c9ead094d7273bcfb Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Wed, 25 Aug 2021 00:17:33 -0400 Subject: [PATCH] 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). --- bin/e | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/e b/bin/e index ea3f990..805e492 100755 --- 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" "$@" -- libgit2 1.1.0