From 148a9fa5b62eeb276ced9c486b6f7830a80d849c Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Thu, 5 Nov 2020 17:09:49 +0100 Subject: [PATCH] add stfu command and its prerequisites --- home/-shrc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/home/-shrc b/home/-shrc index 717832a..b868ce1 100644 --- a/home/-shrc +++ b/home/-shrc @@ -194,6 +194,32 @@ eashare() { printf "%s" "$_REMOTE_DOMAIN/$_REMOTE_DIR/$dest" > /dev/clipboard } +echo2() { + local IFS=" " + printf "%s\n" "$*" >&2 +} + +note() { + local IFS=" " + printf "\033[1m%s\033[0m\n" "$*" >&2 +} + +stfu() { + local ret=0 + "$@" > .stdout 2> .stderr || ret=$? + if test "$ret" -ne 0; then + printf "command failed with exit status %s:\n" "$ret" >&2 + echo2 "$@" + echo2 + note '$ tail -n 20 .stdout' + tail -n 20 .stdout >&2 + echo2 + note '$ tail -n 20 .stderr' + tail -n 20 .stderr >&2 + return "$ret" + fi +} + # sources {{{1 if [ $FANCY -eq 1 ]; then