AutoYADM commit: 2025-03-29 21:30:08

This commit is contained in:
Daniel Fichtinger 2025-03-29 21:30:08 -04:00
parent e5abf22f8f
commit 609c957808

View file

@ -2,6 +2,26 @@
# and copy its url. You can also copy the url of a paste # and copy its url. You can also copy the url of a paste
# you've already uploaded. # you've already uploaded.
function pb --description 'Upload a paste to sr.ht' function pb --description 'Upload a paste to sr.ht'
function select_paste
set -l lines (string split \n (hut paste list) | string trim | string match -rv '^$')
if test (count $lines) -le 1
false
return
end
for i in (seq 1 2 (count $lines))
set -l meta $lines[$i]
set -l filename $lines[(math $i + 1)]
set -l append "$filename: $meta"
if not set -q list
set --function list $append
else
set --function list $list $append
end
end
set -l selection (printf '%s\n' $list | fzf)
set -l hash (string split ' ' $selection)[2]
echo $hash
end
set -l cmd $argv[1] set -l cmd $argv[1]
set -l args $argv[2..] set -l args $argv[2..]
switch $cmd switch $cmd
@ -17,24 +37,25 @@ function pb --description 'Upload a paste to sr.ht'
echo "$url copied to clipboard." echo "$url copied to clipboard."
case copy case copy
set -l lines (string split \n (hut paste list) | string trim | string match -rv '^$') # set -l lines (string split \n (hut paste list) | string trim | string match -rv '^$')
if test (count $lines) -le 1 # if test (count $lines) -le 1
echo 'No pastes found!' # echo 'No pastes found!'
false # false
return # return
end # end
for i in (seq 1 2 (count $lines)) # for i in (seq 1 2 (count $lines))
set -l meta $lines[$i] # set -l meta $lines[$i]
set -l filename $lines[(math $i + 1)] # set -l filename $lines[(math $i + 1)]
set -l append "$filename: $meta" # set -l append "$filename: $meta"
if not set -q list # if not set -q list
set --function list $append # set --function list $append
else # else
set --function list $list $append # set --function list $list $append
end # end
end # end
set -l selection (printf '%s\n' $list | fzf) # set -l selection (printf '%s\n' $list | fzf)
set -l hash (string split ' ' $selection)[2] # set -l hash (string split ' ' $selection)[2]
set -l hash (select_paste)
set -l srht_user (string split ' ' (hut meta show)[1])[1] set -l srht_user (string split ' ' (hut meta show)[1])[1]
set -l url "https://paste.sr.ht/$srht_user/$hash" set -l url "https://paste.sr.ht/$srht_user/$hash"
string trim $url | wl-copy string trim $url | wl-copy