diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-06-12 12:29:18 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-06-12 12:29:18 +1200 |
commit | f5e024daa0ff5d497dfe62d259c0cfebf29aa363 (patch) | |
tree | 69a55e4e800ee70ea9ff2eff1a00b0e6023bd358 | |
parent | Cut down the installation instructions a bit (diff) | |
download | dotfiles-f5e024daa0ff5d497dfe62d259c0cfebf29aa363.tar.gz dotfiles-f5e024daa0ff5d497dfe62d259c0cfebf29aa363.zip |
Add fnp(1df)
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | README.markdown | 2 | ||||
-rw-r--r-- | bin/fnp.sh | 23 | ||||
-rw-r--r-- | man/man1/fnp.1df | 24 |
5 files changed, 51 insertions, 0 deletions
@@ -31,6 +31,7 @@ bin/exm bin/fgscr bin/finc bin/fnl +bin/fnp bin/gms bin/grc bin/grec @@ -100,6 +100,7 @@ BINS = bin/ap \ bin/fgscr \ bin/finc \ bin/fnl \ + bin/fnp \ bin/gms \ bin/grc \ bin/grec \ diff --git a/README.markdown b/README.markdown index 143bdb48..574d3ec3 100644 --- a/README.markdown +++ b/README.markdown @@ -476,6 +476,8 @@ Installed by the `install-bin` target: `find(1)` conditions. * `fnl(1df)` runs a command and saves its output and error into temporary files, printing their paths and line counts. +* `fnp(1df)` prints the given files to stdout, each with a plaintext heading + with the filename in it. * `gms(1df)` runs a set of `getmailrc` files; does much the same thing as the script `getmails` in the `getmail` suite, but runs the requests in parallel and does up to three silent retries using `try(1df)`. diff --git a/bin/fnp.sh b/bin/fnp.sh new file mode 100644 index 00000000..ec68e51f --- /dev/null +++ b/bin/fnp.sh @@ -0,0 +1,23 @@ +# Print input, but include filenames as headings + +# Assume stdin if no options given +[ "$#" -gt 0 ] || set -- - + +# Iterate through arguments +for arg ; do + + # We'll print the filename "-stdin-" rather than - just to be slightly more + # explicit + case $arg in + -) fn=-stdin- ;; + *) fn=$arg ;; + esac + + [ -n "$tail" ] && printf '\n' + tail=1 + + # Form the underline; is there a nicer way to do this in POSIX sh? + ul=$(printf %s "$fn"|tr '[:print:]' -) + printf '%s\n%s\n\n' "$fn" "$ul" + cat -- "$arg" +done diff --git a/man/man1/fnp.1df b/man/man1/fnp.1df new file mode 100644 index 00000000..dc8a07c4 --- /dev/null +++ b/man/man1/fnp.1df @@ -0,0 +1,24 @@ +.TH FNP 1df "June 2017" "Manual page for fnp" +.SH NAME +.B fnp +\- print input with filename headings +.SH SYNOPSIS +.B fnp +FILE1 [FILE2...] +.br +prog1 | +.B +fnp +.br +prog1 | +.B +fnp +FILE1 - FILE2 +.SH DESCRIPTION +.B fnp +prints concatenated standard input from files to standard output, prepending a +filename title with an underline made of hyphen characters to each one. +.SH SEE ALSO +p(1df), pp(1df), pph(1df) +.SH AUTHOR +Tom Ryder <tom@sanctum.geek.nz> |