From 6167a481e00b4670bb69407e515e9fd1bad35f24 Mon Sep 17 00:00:00 2001 From: earnest ma Date: Tue, 21 Dec 2021 21:21:51 -0500 Subject: [PATCH] Add modified paste.sr.ht script --- shp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 shp diff --git a/shp b/shp new file mode 100755 index 0000000..c31ee00 --- /dev/null +++ b/shp @@ -0,0 +1,27 @@ +#!/usr/bin/env sh +set -eu +# Things you need: ~/.config/sr.ht file, curl, jq, xclip + +. ~/.config/sr.ht +PASTESRHT=${PASTESRHT:-https://paste.sr.ht} + +fname=$(zenity --entry) +result=$(xclip -o -sel clip --no-newline | jq -sR '{ + "files": [ + { + "contents": ., + "filename": "'"$fname"'", + } + ], + "visibility": "unlisted" +}' | curl \ + -H Authorization:"token $legacy_token" \ + -H Content-Type:application/json \ + -X POST \ + -d @- $PASTESRHT/api/pastes) + +printf '%s\n' "$result" +sha=$(printf '%s' "$result" | jq -r .sha) +user=$(printf '%s' "$result" | jq -r .user.canonical_name) +xdg-open "$PASTESRHT/$user/$sha" +echo "$PASTESRHT/$user/$sha" | xclip -sel clip