Last active
March 5, 2019 00:01
-
-
Save JeffCarpenter/bd59e2d6dc23e887b4aa3e37612e2730 to your computer and use it in GitHub Desktop.
pipe coloured logs to pste.eu (an HTML pastebin)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOG="/tmp/pste-log" | |
# Dependencies: | |
# - ansi-to-html (https://www.npmjs.com/package/ansi-to-html) | |
# - also sed, curl, expect (includes unbuffer) and Perl | |
function log { | |
unbuffer makepkg 2>&1 | tee /dev/tty > "$LOG" | |
} | |
function post-log { | |
_post-log "$LOG" | |
} | |
function _post-log { | |
tmp_html="$(mktemp /tmp/pste-html.XXXXXX)" && | |
exec 3> "$tmpfile" && | |
rm "$tmpfile" && | |
ansi-to-html "$1" | | |
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/<br>/g' > $tmp_html && | |
html="$(cat $tmp_html)" | |
curl -XPOST --data html-text="$html" https://pste.eu | | |
perl -nle 'print for /https:\/\/pste\.eu\/p\/[^.]+\.html/g' | | |
head -n1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment