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
# you've already uploaded.
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 args $argv[2..]
switch $cmd
@ -17,24 +37,25 @@ function pb --description 'Upload a paste to sr.ht'
echo "$url copied to clipboard."
case copy
set -l lines (string split \n (hut paste list) | string trim | string match -rv '^$')
if test (count $lines) -le 1
echo 'No pastes found!'
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]
# set -l lines (string split \n (hut paste list) | string trim | string match -rv '^$')
# if test (count $lines) -le 1
# echo 'No pastes found!'
# 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]
set -l hash (select_paste)
set -l srht_user (string split ' ' (hut meta show)[1])[1]
set -l url "https://paste.sr.ht/$srht_user/$hash"
string trim $url | wl-copy