aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-06-12 12:29:18 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-06-12 12:29:18 +1200
commitf5e024daa0ff5d497dfe62d259c0cfebf29aa363 (patch)
tree69a55e4e800ee70ea9ff2eff1a00b0e6023bd358 /bin
parentCut down the installation instructions a bit (diff)
downloaddotfiles-f5e024daa0ff5d497dfe62d259c0cfebf29aa363.tar.gz
dotfiles-f5e024daa0ff5d497dfe62d259c0cfebf29aa363.zip
Add fnp(1df)
Diffstat (limited to 'bin')
-rw-r--r--bin/fnp.sh23
1 files changed, 23 insertions, 0 deletions
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