AutoYADM commit: 2025-03-29 21:45:07
This commit is contained in:
parent
609c957808
commit
b1dffe01c0
1 changed files with 32 additions and 24 deletions
|
@ -22,6 +22,13 @@ function pb --description 'Upload a paste to sr.ht'
|
||||||
set -l hash (string split ' ' $selection)[2]
|
set -l hash (string split ' ' $selection)[2]
|
||||||
echo $hash
|
echo $hash
|
||||||
end
|
end
|
||||||
|
function get_user
|
||||||
|
if set -q srht_user
|
||||||
|
echo "~$srht_user"
|
||||||
|
else
|
||||||
|
string split ' ' (hut meta show)[1][1]
|
||||||
|
end
|
||||||
|
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
|
||||||
|
@ -37,32 +44,33 @@ 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 hash (select_paste; or 1)
|
||||||
# if test (count $lines) -le 1
|
if test hash = 1
|
||||||
# echo 'No pastes found!'
|
echo 'Error selecting a paste!'
|
||||||
# false
|
return 1
|
||||||
# return
|
end
|
||||||
# end
|
set -l url "https://paste.sr.ht/$(get_user)/$hash"
|
||||||
# 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
|
string trim $url | wl-copy
|
||||||
echo "$url copied to clipboard."
|
echo "$url copied to clipboard."
|
||||||
|
case delete
|
||||||
|
set -l hash (select_paste; or 1)
|
||||||
|
if test hash = 1
|
||||||
|
echo 'Error selecting a paste!'
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
hut paste delete $hash
|
||||||
|
echo $hash 'deleted successfully!'
|
||||||
|
case show
|
||||||
|
set -l hash (select_paste; or 1)
|
||||||
|
if test hash = 1
|
||||||
|
echo 'Error selecting a paste!'
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
hut paste show $hash
|
||||||
|
case id
|
||||||
|
select_paste; or return 1
|
||||||
case '*'
|
case '*'
|
||||||
echo 'Unhandled case!'
|
echo 'Unknown arguments!'
|
||||||
false
|
return 1
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue