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,24 +2,9 @@
# 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'
set -l cmd $argv[1] function select_paste
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) | 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!'
false false
return return
end end
@ -35,6 +20,42 @@ function pb --description 'Upload a paste to sr.ht'
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]
echo $hash
end
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) | 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 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