pastes-sh.kak

· ficd's pastes · raw

expires: 2025-10-24

 1define-command -docstring %{
 2    pastes [<name>]: paste the selection(s) to pastes.sh. Separate
 3    selections are appended into one. Resulting URL is printed to *debug*
 4    and copied to clipboard.
 5    Arguments:
 6        name  optional filename for the paste
 7} -params 0..1 pastes %{
 8    evaluate-commands -draft -save-regs '"ab|' %{
 9        set-register b %val{bufname}
10        execute-keys '"ay'
11        edit -scratch
12        set-register | "ssh pastes.sh %arg{1} 2>/dev/null"
13        execute-keys '"a<a-R>%|<ret>%s\r<ret>d%_"ay'
14        set-register | "wl-copy -n"
15        execute-keys '<a-|><ret>'
16        echo -debug %reg{a}
17        hook -once global WinDisplay %exp{\Q%reg{b}\E} %{
18            info -title 'pastes.sh' "%reg{a}"
19        }
20        delete-buffer
21    }
22}