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