aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-02 11:26:39 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-02 11:26:39 +1200
commitca632bed9240bce35c6acffceeec7c46a3d9b3f1 (patch)
tree8c17a2f236f7146b78157239e75cd4fb2d3784a5 /bin
parentStrip trailing newline from clrd() (diff)
downloaddotfiles-ca632bed9240bce35c6acffceeec7c46a3d9b3f1.tar.gz
dotfiles-ca632bed9240bce35c6acffceeec7c46a3d9b3f1.zip
Move clrd()/clwr() to scripts
clrd(1) is POSIX sh, but clwr(1) ideally needs Readline, so I've left it as #!/bin/bash for now.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/clrd11
-rw-r--r--bin/clwr16
2 files changed, 27 insertions, 0 deletions
diff --git a/bin/clrd b/bin/clrd
new file mode 100755
index 00000000..0e41d2db
--- /dev/null
+++ b/bin/clrd
@@ -0,0 +1,11 @@
+#!/bin/sh
+self=clrd
+if [ "$#" -ne 1 ] ; then
+ printf >&2 '%s: Need input file\n' "$self"
+ exit 2
+elif ! [ -t 1 ] ; then
+ printf >&2 '%s: stdout not a terminal\n' "$self"
+ exit 2
+fi
+clear
+tail -f -- "$@"
diff --git a/bin/clwr b/bin/clwr
new file mode 100644
index 00000000..677e0a24
--- /dev/null
+++ b/bin/clwr
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+self=clwr
+if (($# != 1)) ; then
+ printf >&2 '%s: Need output file\n' "$self"
+ exit 2
+elif [[ ! -t 0 ]] ; then
+ printf >&2 '%s: stdin not a terminal\n' "$self"
+ exit 2
+elif [[ ! -t 1 ]] ; then
+ printf >&2 '%s: stdout not a terminal\n' "$self"
+ exit 2
+fi
+exec 3>"$1"
+while { clear && IFS= read -er line ; } ; do
+ printf '%s\n' >&3
+done