summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/.gitignore1
-rw-r--r--bin/Makefile3
-rw-r--r--bin/README3
-rw-r--r--bin/bin.75
-rw-r--r--bin/edit.sh9
-rw-r--r--bin/man1/edit.134
6 files changed, 52 insertions, 3 deletions
diff --git a/bin/.gitignore b/bin/.gitignore
index 3bf8cbc0..b31a9d08 100644
--- a/bin/.gitignore
+++ b/bin/.gitignore
@@ -6,6 +6,7 @@ bit
 bri
 config.mk
 dtch
+edit
 ever
 fbatt
 fbclock
diff --git a/bin/Makefile b/bin/Makefile
index 6f7f89dc..3eb71c62 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -15,6 +15,7 @@ BINS_ANY += aes
 BINS_ANY += beef
 BINS_ANY += bit
 BINS_ANY += dtch
+BINS_ANY += edit
 BINS_ANY += glitch
 BINS_ANY += hi
 BINS_ANY += hnel
@@ -59,7 +60,7 @@ linux: meta ${BINS_LINUX}
 
 tls: meta ${BINS_TLS}
 
-meta: tags .gitignore
+meta: tags .gitignore README
 
 # Binaries
 
diff --git a/bin/README b/bin/README
index ddca3e0b..240dd757 100644
--- a/bin/README
+++ b/bin/README
@@ -12,6 +12,7 @@ DESCRIPTION
      bit(1)      calculator
      bri(1)      backlight brightness control
      dtch(1)     detached sessions
+     edit(1)     interactive script
      ever(1)     watch files
      fbatt(1)    framebuffer battery indicator
      fbclock(1)  framebuffer clock
@@ -37,4 +38,4 @@ DESCRIPTION
 
      png(3)  basic PNG output
 
-Causal Agency                   August 28, 2019                  Causal Agency
+Causal Agency                   August 29, 2019                  Causal Agency
diff --git a/bin/bin.7 b/bin/bin.7
index af3bf225..0d7a1bae 100644
--- a/bin/bin.7
+++ b/bin/bin.7
@@ -1,4 +1,4 @@
-.Dd August 28, 2019
+.Dd August 29, 2019
 .Dt BIN 7
 .Os "Causal Agency"
 .
@@ -31,6 +31,9 @@ backlight brightness control
 .It Xr dtch 1
 detached sessions
 .
+.It Xr edit 1
+interactive script
+.
 .It Xr ever 1
 watch files
 .
diff --git a/bin/edit.sh b/bin/edit.sh
new file mode 100644
index 00000000..c276707f
--- /dev/null
+++ b/bin/edit.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+set -eu
+
+script=$(mktemp)
+trap "rm -f '$script'" EXIT
+
+sed "s/.*/${1:-: &}/" >> "$script"
+$EDITOR "$script"
+sh -eux "$script"
diff --git a/bin/man1/edit.1 b/bin/man1/edit.1
new file mode 100644
index 00000000..8c94939a
--- /dev/null
+++ b/bin/man1/edit.1
@@ -0,0 +1,34 @@
+.Dd August 29, 2019
+.Dt EDIT 1
+.Os
+.
+.Sh NAME
+.Nm edit
+.Nd interactive script
+.
+.Sh SYNOPSIS
+.Nm
+.Op Ar replacement
+.
+.Sh DESCRIPTION
+.Nm
+creates a temporary
+.Xr sh 1
+script
+from standard input
+and invokes
+.Ev EDITOR
+before it executes.
+The
+.Ar replacement
+argument is used in a
+.Xr sed 1
+substitute expression
+to generate the script.
+The default
+.Ar replacement
+is
+.Ql : & .
+.
+.Sh EXAMPLES
+.Dl ls | edit 'mv & &'