summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
+}