aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-10-14 17:28:28 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-10-14 17:28:28 +1300
commitdd2171f0491e8e723b9f3e658d484ec9eece1d2d (patch)
tree9986013a5e2b4884167111f0ed74669ba73b5c28 /bin
parentRemove unneeded quotes from br(1df) man page (diff)
downloaddotfiles-dd2171f0491e8e723b9f3e658d484ec9eece1d2d.tar.gz
dotfiles-dd2171f0491e8e723b9f3e658d484ec9eece1d2d.zip
Add ap(1df) and bp(1df)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ap34
-rwxr-xr-xbin/bp3
2 files changed, 37 insertions, 0 deletions
diff --git a/bin/ap b/bin/ap
new file mode 100755
index 00000000..b6ee36d4
--- /dev/null
+++ b/bin/ap
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Run a program with args read from standard input, prompted if from term
+if [ "$#" -eq 0 ] ; then
+ printf >&2 'ap: Need at least one argument (command name)\n'
+ exit 2
+fi
+
+# Get the command name and shift it off
+cmd=$1
+shift
+
+# Iterate through the remaining args; it's legal for there to be none, but in
+# that case the user may as well just have invoked the command directly
+for arg ; do
+
+ # If this is the first iteration, clear the params away (we grabbed them in
+ # the for statement)
+ if [ -z "$reset" ] ; then
+ set --
+ reset=1
+ fi
+
+ # If stdin is a terminal, prompt with the name of the argument
+ if [ -t 0 ] ; then
+ printf '%s: ' "$arg"
+ fi
+
+ # Note that a whitespace or even empty argument is allowed
+ IFS= read -r val
+ set -- "$@" "$val"
+done
+
+# Execute the command with the given parameters
+exec "$cmd" "$@"
diff --git a/bin/bp b/bin/bp
new file mode 100755
index 00000000..6b78fbbc
--- /dev/null
+++ b/bin/bp
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Read an URL and then browse to it, saving the annoyance of quoting URLs
+ap br URL