From edf5f905cfa8e4d5f41791abe7ead43b7070fa9a Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Mon, 28 Sep 2020 23:40:00 -0400 Subject: [PATCH] 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 :) --- bin/bed | 17 +++++++++++++++++ etc/edinputrc | 7 +++++++ 2 files changed, 24 insertions(+) create mode 100755 bin/bed create mode 100644 etc/edinputrc diff --git a/bin/bed b/bin/bed new file mode 100755 index 0000000..821901b --- /dev/null +++ b/bin/bed @@ -0,0 +1,17 @@ +#!/bin/sh +# bed -- [slightly] better ed +for f in .tags tags; do + if [ -e "$f" ]; then + echo "using tags from ./$f" + COMP="$COMP --file=$f" + fi +done + +export INPUTRC="$HOME/etc/edinputrc" + +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 new file mode 100644 index 0000000..025d8ac --- /dev/null +++ b/etc/edinputrc @@ -0,0 +1,7 @@ +$include ~/.inputrc + +# Since this is ed(1) we want to use C-n/C-p for +# completion (tabs should be tabs) +Control-n: complete +Control-p: complete-backward +TAB: tab-insert -- libgit2 0.28.4