25 lines
731 B
Fish
25 lines
731 B
Fish
function pb --description 'Upload a paste to sr.ht'
|
|
set -l cmd $argv[1]
|
|
set -l args $argv[2..]
|
|
switch $cmd
|
|
case create
|
|
set -l output (hut paste create $args)
|
|
if not test $status = 0
|
|
echo 'Error creating paste!'
|
|
false
|
|
return
|
|
end
|
|
set -l url (string match -r 'https://paste\.sr\.ht/.+/[a-zA-Z0-9]+$' $output)
|
|
echo $url | wl-copy
|
|
echo "$url copied to clipboard."
|
|
|
|
case copy
|
|
set -l lines (string split \n (hut paste list))
|
|
echo $lines
|
|
case '*'
|
|
echo 'Unhandled case!'
|
|
# echo ">$cmd<"
|
|
false
|
|
return
|
|
end
|
|
end
|