From eb37932b8d28a25af648536bf7ab586b6acd47c8 Mon Sep 17 00:00:00 2001 From: Till Höppner Date: Fri, 19 May 2017 18:58:11 +0200 Subject: Pastebin functions --- conf.d/99-pastebin.zsh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 conf.d/99-pastebin.zsh (limited to 'conf.d/99-pastebin.zsh') diff --git a/conf.d/99-pastebin.zsh b/conf.d/99-pastebin.zsh new file mode 100644 index 0000000..3eb3f36 --- /dev/null +++ b/conf.d/99-pastebin.zsh @@ -0,0 +1,34 @@ +: ${PB_INSTANCE:=ptpb.pw} +: ${PB_CURL_ARGS:=""} + +PASTE_LOG_FILE=$HOME/.local/zsh/ptpb.log + +# pb upload +function pbu() { + local tmp=$(mktemp) + + if [ "$#" -eq 0 ]; then + # paste from stdin + curl $PB_CURL_ARGS -sF c=@- https://$PB_INSTANCE > $tmp + else + curl $PB_CURL_ARGS -sF c=@$1 https://$PB_INSTANCE > $tmp + fi + + mkdir -p $(dirname $PASTE_LOG_FILE) + { cat $tmp; echo; } | tee -a $PASTE_LOG_FILE + cat $tmp | awk '/url/ { print $2 }' | tr -d '\n' | xclip -i + + rm $tmp +} + +# pb delete, takes short id +# someone please fix this +function pbd() { + local short=$(grep -C2 $1 $PASTE_LOG_FILE \ + | awk '/uuid/ { print $2 }') + curl $PB_CURL_ARGS -X DELETE https://$PB_INSTANCE/$short +} + +function termbin() { + nc termbin.com 9999 +} -- cgit v1.2.3