Add modified paste.sr.ht script

pull/1/head
earnest ma 2021-12-21 21:21:51 -05:00
parent 52743add35
commit 6167a481e0
Signed by: earnest ma
GPG Key ID: A343F43342EB6E2A
1 changed files with 27 additions and 0 deletions

27
shp Executable file
View File

@ -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