aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.markdown4
-rw-r--r--bash/bashrc.d/clrd.bash5
-rw-r--r--bash/bashrc.d/clwr.bash8
-rwxr-xr-xbin/clrd11
-rw-r--r--bin/clwr16
-rw-r--r--man/man1/clrd.116
-rw-r--r--man/man1/clwr.116
7 files changed, 61 insertions, 15 deletions
diff --git a/README.markdown b/README.markdown
index acbe8d3a..5e3eb501 100644
--- a/README.markdown
+++ b/README.markdown
@@ -185,8 +185,6 @@ I also add completions for my own scripts and functions where useful.
There are a few other little tricks in `bash/bashrc.d`, including:
* `bd` changes into a named ancestor of the current directory.
-* `clrd` sets up a per-line file read, clearing the screen first
-* `clwr` sets up a per-line file write, clearing the screen before each line
* `fnl` runs a command and save its output and error into temporary files.
* `hgrep` searches `$HISTFILE`.
* `keep` stores ad-hoc shell functions and variables.
@@ -317,6 +315,8 @@ Installed by the `install-bin` target:
* `bel(1)` prints a terminal bell character
* `ca(1)` prints a count of its given arguments.
* `cf(1)` prints a count of entries in a given directory.
+* `clrd(1)` sets up a per-line file read, clearing the screen first
+* `clwr(1)` sets up a per-line file write, clearing the screen before each line
* `dub(1)` lists the biggest entries in a directory.
* `edda(1)` provides a means to run `ed(1)` over a set of files preserving
any options, mostly useful for scripts.
diff --git a/bash/bashrc.d/clrd.bash b/bash/bashrc.d/clrd.bash
deleted file mode 100644
index 145fc108..00000000
--- a/bash/bashrc.d/clrd.bash
+++ /dev/null
@@ -1,5 +0,0 @@
-# Clear screen, start tail -f on a file
-clrd() {
- clear
- tail -f
-}
diff --git a/bash/bashrc.d/clwr.bash b/bash/bashrc.d/clwr.bash
deleted file mode 100644
index 455484d9..00000000
--- a/bash/bashrc.d/clwr.bash
+++ /dev/null
@@ -1,8 +0,0 @@
-# Clear screen, accept line, write to all args, loop; use this as e.g. an input
-# tmux window for a minimal IRC client like ii(1). Uses read -e to allow
-# newlines.
-clwr() {
- while { clear && IFS= read -er line ; } ; do
- printf '%s\n' "$line"
- done
-}
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
diff --git a/man/man1/clrd.1 b/man/man1/clrd.1
new file mode 100644
index 00000000..696b3303
--- /dev/null
+++ b/man/man1/clrd.1
@@ -0,0 +1,16 @@
+.TH CLRD 1 "August 2016" "Manual page for clrd"
+.SH NAME
+.B clrd
+\- clear the screen and run tail on the arguments
+.SH SYNOPSIS
+.B clrd
+file
+.SH DESCRIPTION
+.B clrd
+clears the screen and runs tail -f on the given file. It will not run if stdout
+is not a terminal. This is for use in minimal socket-network programs like
+ii(1), along with clwr(1).
+.SH SEE ALSO
+clwr(1), ii(1)
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/clwr.1 b/man/man1/clwr.1
new file mode 100644
index 00000000..5b5a1eee
--- /dev/null
+++ b/man/man1/clwr.1
@@ -0,0 +1,16 @@
+.TH CLWR 1 "August 2016" "Manual page for clwr"
+.SH NAME
+.B clwr
+\- clear screen, accept Readline line, write line
+.SH SYNOPSIS
+.B clwr
+file
+.SH DESCRIPTION
+.B clwr
+clears the screen, accepts a line of Readline input from stdin, writes it to
+the given file, and loops. This is for use in minimal socket-network programs
+like ii(1), along with clrd(1).
+.SH SEE ALSO
+clrd(1), ii(1)
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>