summaryrefslogtreecommitdiff
path: root/conf.d/99-pastebin.zsh
diff options
context:
space:
mode:
authorTill Höppner2017-05-19 18:58:11 +0200
committerTill Höppner2017-05-19 19:00:00 +0200
commiteb37932b8d28a25af648536bf7ab586b6acd47c8 (patch)
treed1f192566e00f7d9ea2728de41d64a2733a0daa6 /conf.d/99-pastebin.zsh
parentedcbd311a1008d04b3281ef026db437efb6f9958 (diff)
downloadzsh-eb37932b8d28a25af648536bf7ab586b6acd47c8.tar.gz
zsh-eb37932b8d28a25af648536bf7ab586b6acd47c8.tar.xz
zsh-eb37932b8d28a25af648536bf7ab586b6acd47c8.zip
Pastebin functions
Diffstat (limited to 'conf.d/99-pastebin.zsh')
-rw-r--r--conf.d/99-pastebin.zsh34
1 files changed, 34 insertions, 0 deletions
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
+}