aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-05-12 15:20:07 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-05-12 19:26:14 +1200
commit1a3ae549beac1445e1bb44a809f3245e67ed0dfd (patch)
treea41e9d07117a92e654d40922f5677cb170ef77c9
parentMerge branch 'hotfix/v8.35.1' into develop (diff)
downloaddotfiles-1a3ae549beac1445e1bb44a809f3245e67ed0dfd.tar.gz
dotfiles-1a3ae549beac1445e1bb44a809f3245e67ed0dfd.zip
Add qat(1df), implementing an item from IDEAS.md
-rw-r--r--.gitignore1
-rw-r--r--IDEAS.md2
-rw-r--r--Makefile1
-rw-r--r--README.md1
-rwxr-xr-xbin/qat.sh12
-rw-r--r--man/man1/qat.1df19
6 files changed, 34 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index b2601fbc..f060708e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -98,6 +98,7 @@
/bin/pst.sh
/bin/pvi
/bin/pwg
+/bin/qat
/bin/quo
/bin/rep
/bin/rfcf
diff --git a/IDEAS.md b/IDEAS.md
index 7622dd97..092a604c 100644
--- a/IDEAS.md
+++ b/IDEAS.md
@@ -3,8 +3,6 @@ Ideas
* A wrapper `ksw(1df)` (kill-switch) that traps `SIGINT` to kill a called
program or loop immediately, rather than aborting a loop (is this possible?)
-* A wrapper `sil(1df)` or `nec(1df)` to turn `stty -echo` off for the duration
- of a paste?
* I can probably share my `psql()` completions/shortcuts after sanitizing them
a bit
* Wouldn't be too hard to add some HTTP BASIC authentication to `ix(1df)` to
diff --git a/Makefile b/Makefile
index 498af984..b93d5e4b 100644
--- a/Makefile
+++ b/Makefile
@@ -179,6 +179,7 @@ BINS = bin/ap \
bin/pst \
bin/pvi \
bin/pwg \
+ bin/qat \
bin/quo \
bin/rep \
bin/rfcf \
diff --git a/README.md b/README.md
index 6346c455..eb383653 100644
--- a/README.md
+++ b/README.md
@@ -573,6 +573,7 @@ These scripts are installed by the `install-bin` target:
[`plenv`](https://github.com/tokuhirom/plenv), filters out any modules in
`~/.plenv/non-cpan-modules`, and updates them all.
* `pwg(1df)` generates just one decent password with `pwgen(1)`.
+* `qat(1df)` disables `stty echo` for the duration of a paste.
* `rep(1df)` repeats a command a given number of times.
* `rgl(1df)` is a very crude interactive `grep(1)` loop.
* `shb(1df)` attempts to build shebang lines for scripts from the system paths.
diff --git a/bin/qat.sh b/bin/qat.sh
new file mode 100755
index 00000000..31f5e8dd
--- /dev/null
+++ b/bin/qat.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+restore() {
+ if [ -n "$stty" ] ; then
+ stty "$stty"
+ fi
+}
+trap restore EXIT
+if [ -t 0 ] ; then
+ stty=$(stty -g)
+ stty -echo
+fi
+cat
diff --git a/man/man1/qat.1df b/man/man1/qat.1df
new file mode 100644
index 00000000..d7466b3a
--- /dev/null
+++ b/man/man1/qat.1df
@@ -0,0 +1,19 @@
+.TH QAT 1df "May 2020" "Manual page for qat"
+.SH NAME
+.B qat
+\- quiet cat for terminal pastes
+.SH SYNOPSIS
+.B qat
+| wc -l
+.br
+.B qat
+| grep pattern
+.SH DESCRIPTION
+.B qat
+switches the echo feature for stty(1) off for the duration of a cat(1). You
+can use this to paste stuff into a pipeline without the terminal echoing it
+back at you.
+.SH SEE ALSO
+stty(1)
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>