diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-01-06 13:59:26 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-01-06 13:59:26 +1300 |
commit | 13d4998ee636abbb5bf1b20acd5b19ecd8af0578 (patch) | |
tree | 91c7be8c6a76d8653fdae8feec0357cb0d2d89ed | |
parent | Add jfp(1df) (diff) | |
download | dotfiles-13d4998ee636abbb5bf1b20acd5b19ecd8af0578.tar.gz dotfiles-13d4998ee636abbb5bf1b20acd5b19ecd8af0578.zip |
Add pp(1df) and pph(1df)
-rw-r--r-- | README.markdown | 2 | ||||
-rwxr-xr-x | bin/pp | 14 | ||||
-rwxr-xr-x | bin/pph | 5 | ||||
-rw-r--r-- | man/man1/pp.1df | 17 | ||||
-rw-r--r-- | man/man1/pph.1df | 16 |
5 files changed, 54 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown index e2abeb96..97823267 100644 --- a/README.markdown +++ b/README.markdown @@ -478,6 +478,8 @@ Installed by the `install-bin` target: * `motd(1df)` shows the system MOTD. * `onl(1df)` crunches input down to one printable line. * `pa(1df)` prints its arguments, one per line. +* `pp(1df)` prints the full path of each argument using `$PWD`. +* `pph(1df)` runs `pp(1df)` and includes a leading `$HOSTNAME:`. * `paz(1df)` print its arguments terminated by NULL chars. * `pit(1df)` runs its input through a pager if its standard output looks like a terminal. @@ -0,0 +1,14 @@ +#!/bin/sh +# Print the full path to each argument; file need not exist +for arg ; do + case $arg in + */*) + dir=$(cd -- "${arg%/*}" ; printf '%s/' "$PWD") + dir=${dir%/} + ;; + *) + dir=$PWD + ;; + esac + printf '%s/%s\n' "$dir" "${arg##*/}" +done diff --git a/bin/pph b/bin/pph new file mode 100755 index 00000000..684aaafd --- /dev/null +++ b/bin/pph @@ -0,0 +1,5 @@ +#!/bin/sh +# Run pp(1df) on args, prefix with machine hostname +hostname=$(hostname -s) || exit +pp "$@" | +sed 's_^_'"$hostname":'_' diff --git a/man/man1/pp.1df b/man/man1/pp.1df new file mode 100644 index 00000000..1c7aca70 --- /dev/null +++ b/man/man1/pp.1df @@ -0,0 +1,17 @@ +.TH PP 1df "January 2017" "Manual page for pp" +.SH NAME +.B pp +\- print the full path to each argument +.SH SYNOPSIS +.B pp +/arg arg2 ./arg3 +.SH DESCRIPTION +.B pp +uses $PWD to print the full path to each of its arguments, unless they begin +with a slash, in which case they are printed verbatim. +.SH CAVEATS +Newlines in filenames will still work, but the results won't really make sense +as they'll be indistinguishable from newlines separating the files. This is for +generating human-readable file lists, not for machines. +.SH AUTHOR +Tom Ryder <tom@sanctum.geek.nz> diff --git a/man/man1/pph.1df b/man/man1/pph.1df new file mode 100644 index 00000000..0ad98fc5 --- /dev/null +++ b/man/man1/pph.1df @@ -0,0 +1,16 @@ +.TH PPH 1df "January 2017" "Manual page for pp" +.SH NAME +.B pp +\- print the full path to each argument, hostname prepended +.SH SYNOPSIS +.B pp +/arg arg2 ./arg3 +.SH DESCRIPTION +.B pph +runs pp(1df) on the arguments to print the full path to each one, and also +prepends the machine's hostname and a colon to each line. +.SH CAVEATS +Newlines in filenames will mess this up. This is for generating human-readable +file lists, not for machines. +.SH AUTHOR +Tom Ryder <tom@sanctum.geek.nz> |