From 609c957808ccdc2be0a5816bbf89bb814761c6b9 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Sat, 29 Mar 2025 21:30:08 -0400 Subject: [PATCH] AutoYADM commit: 2025-03-29 21:30:08 --- .config/fish/functions/pb.fish | 57 +++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/.config/fish/functions/pb.fish b/.config/fish/functions/pb.fish index 89d70f87..3dea907c 100644 --- a/.config/fish/functions/pb.fish +++ b/.config/fish/functions/pb.fish @@ -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