summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2018-05-28 22:42:40 +0200
committerTharre <tharre3@gmail.com>2018-05-28 22:44:41 +0200
commitc43e7ad8741ae381633a33e8213fdfb74bfc6ce6 (patch)
tree3c2ecdaff8a54a34ea96a34d43ffe0a5ac27b314 /bin
parent9ab1de9c17ff6e082939f4635d633bcbc5449ef9 (diff)
downloaddotfiles-c43e7ad8741ae381633a33e8213fdfb74bfc6ce6.tar.gz
dotfiles-c43e7ad8741ae381633a33e8213fdfb74bfc6ce6.tar.xz
dotfiles-c43e7ad8741ae381633a33e8213fdfb74bfc6ce6.zip
Add capture_output script
Diffstat (limited to 'bin')
-rwxr-xr-xbin/capture_output15
1 files changed, 15 insertions, 0 deletions
diff --git a/bin/capture_output b/bin/capture_output
new file mode 100755
index 0000000..8645f3f
--- /dev/null
+++ b/bin/capture_output
@@ -0,0 +1,15 @@
+#!/bin/bash -e
+
+if ! [ -x "$(command -v pbpst)" ]; then
+ echo 'Error: pbpst is not installed' >&2
+ exit 1
+fi
+
+if [ $# -eq 0 ]; then
+ echo 'Error: no arguments supplied' >&2
+ exit 1
+fi
+
+# sed removes all of the coloring, and (hopefully) all the other escape
+# sequences that col doesn't deal with well.
+script -qfe >(sed 's:\x1B\[[0-9;?]*[mKJl]::g; 1d; $d' | col -bx | pbpst -S -x1d) -c "$*"