commit 8b1dd067d6dd60f448ddce7977cc99c3aebd636b (patch)
Author: Alex Karle <firstname.lastname@example.org>
Date: Sun, 23 Jan 2022 23:14:54 -0500
bin: Add `e` program to launch ed(1) with a prompt
I'm back on the ed(1) train, and the prompt is definitely a must.
Pro tip of the day--I always wanted to filter lines through an
external program and read it back, and thought it wasn't possible
in one command. Something like vi's !motion command.
Turns out it is! The trick is that the `e` command can take in a
!command, *replacing the contents of the buffer without changing
the default filename*. So, to reformat the buffer, just write it
out first and then:
> e !fmt < %
Voila! I used it on this commit :)
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/bin/e b/bin/e
@@ -0,0 +1,6 @@
+# NOTE: disabling rlwrap for now due to TAB being captured :(
+# exec rlwrap ed -p'> ' "$@"
+exec ed -p'> ' "$@"