~sircmpwn/dotfiles

ref: fa8c0e062fe75fcc9cf14fbea23ef78f6b38df57 dotfiles/bin/paste -rwxr-xr-x 581 bytes
fa8c0e06Drew DeVault paste: update token variable name 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh -eu
. ~/.config/sr.ht
PASTESRHT=${PASTESRHT:-https://paste.sr.ht}
fname=$(dmenu -p 'File name: ' </dev/null)
result=$(wl-paste --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"
wl-copy "$PASTESRHT/$user/$sha"