commit edf5f905cfa8e4d5f41791abe7ead43b7070fa9a (patch)
Author: Alex Karle <firstname.lastname@example.org>
Date: Mon, 28 Sep 2020 23:40:00 -0400
bed: A slightly better take on The Standard Editor
I've been having a lot of fun learning about ed(1) and all its
quirks (basic regular expressions, etc). As a vi(m) enthusiast,
it seems like a good thing to learn (even just for BRE's, which
both sed and grep use by default).
In my adventures with ed(1), it's been decidedly easier to use
with rlwrap(1), a small program to wrap the input in readline
so that I get completions, history, and in-line editing (I mean,
ed(1) just uses getc(), which leaves it up to the kernel to
handle the buffered stdin stream (and it doesn't do arrow keys!)).
This small `bed` script is the outcome of my journey -- mostly
just a collection of rlwrap settings I like to use (ed(1) has no
settings :) ), along with a slightly tweaked inputrc for ed(1) use.
This commit message brought to you by `bed`. Maybe I'll come up
with a better name, but it hit the point of dotfile-check-in :)
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/bin/bed b/bin/bed
@@ -0,0 +1,17 @@
+# bed -- [slightly] better ed
+for f in .tags tags; do
+ if [ -e "$f" ]; then
+ echo "using tags from ./$f"
+ COMP="$COMP --file=$f"
+exec rlwrap \
+ --complete-filenames \
+ --logfile /tmp/rled.log \
+ --histsize 10000 $COMP \
+ --extra-char-after-completion '' \
+ ed -v -p"> " "$@"
diff --git a/etc/edinputrc b/etc/edinputrc
@@ -0,0 +1,7 @@
+# Since this is ed(1) we want to use C-n/C-p for
+# completion (tabs should be tabs)