AutoYADM commit: 2025-06-08 22:49:47
This commit is contained in:
parent
ee9af11e5e
commit
9c499a221b
1 changed files with 17 additions and 9 deletions
|
@ -2,6 +2,8 @@ declare-option -docstring %{
|
|||
Command for copying to system clipboard.
|
||||
} str clipboard_copy_cmd 'wl-copy'
|
||||
|
||||
declare-option int clip_selcount 0
|
||||
|
||||
define-command -docstring %{
|
||||
clip-copy [-split]: copy selections to system clipboard
|
||||
Set the clipboard_copy_cmd option to change the command
|
||||
|
@ -10,6 +12,7 @@ define-command -docstring %{
|
|||
} -params 0..1 clipboard-copy %{
|
||||
# preserve registers
|
||||
evaluate-commands -save-regs 'a|' %{
|
||||
set-option local clip_selcount %val{selection_count}
|
||||
# copy selections
|
||||
execute-keys '"ay'
|
||||
# disposable buffer
|
||||
|
@ -18,16 +21,21 @@ define-command -docstring %{
|
|||
set-register | %opt{clipboard_copy_cmd}
|
||||
# branch based on switch
|
||||
execute-keys %sh{
|
||||
if [ ${#} = 1 ] && [ ${1} = '-split' ]; then
|
||||
# paste all
|
||||
# reduce selections to those without newline
|
||||
# append a newline
|
||||
# delete trailing newline
|
||||
# select all, pipe to copy cmd
|
||||
echo '"a<a-P><a-K>\n<ret>a<ret><esc>gjd%<a-|><ret>'
|
||||
if [ "$kak_opt_clip_selcount" -gt 1 ]; then
|
||||
if [ ${#} = 1 ] && [ ${1} = '-split' ]; then
|
||||
# paste all
|
||||
# reduce selections to those without newline
|
||||
# append a newline
|
||||
# delete extra newlines
|
||||
# select all, pipe to copy cmd
|
||||
echo '"a<a-P><a-K>\n<ret>a<ret><esc>gjd%<a-|><ret>'
|
||||
printf 'gj:try %%{ exec <a-k>\\n<ret> }'
|
||||
else
|
||||
# paste all, select all, pipe to copy cmd
|
||||
echo '"a<a-P>%<a-|><ret>'
|
||||
fi
|
||||
else
|
||||
# paste all, select all, pipe to copy cmd
|
||||
echo '"a<a-P>%<a-|><ret>'
|
||||
echo '<a-|><ret>'
|
||||
fi
|
||||
}
|
||||
# clean up
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue