AutoYADM commit: 2025-06-08 22:34:46
This commit is contained in:
parent
a2516ffcc0
commit
ee9af11e5e
1 changed files with 17 additions and 30 deletions
|
@ -1,5 +1,3 @@
|
|||
# TODO: Make it so that each selection is split by only a single newline,
|
||||
# ie if the selection already has a newline at the end then don't add another one
|
||||
declare-option -docstring %{
|
||||
Command for copying to system clipboard.
|
||||
} str clipboard_copy_cmd 'wl-copy'
|
||||
|
@ -8,48 +6,37 @@ define-command -docstring %{
|
|||
clip-copy [-split]: copy selections to system clipboard
|
||||
Set the clipboard_copy_cmd option to change the command
|
||||
Switches:
|
||||
-split separate each selection with a newline
|
||||
} -params 0..1 clip-copy %{
|
||||
-split ensure each selection separated by newline
|
||||
} -params 0..1 clipboard-copy %{
|
||||
# preserve registers
|
||||
evaluate-commands -save-regs 'a|' %{
|
||||
# copy selections
|
||||
execute-keys '"ay'
|
||||
# disposable buffer
|
||||
edit -scratch
|
||||
# set shell register to copy command
|
||||
set-register | %opt{clipboard_copy_cmd}
|
||||
# branch based on switch
|
||||
execute-keys %sh{
|
||||
if [ ${#} = 1 ] && [ ${1} = '-split' ]; then
|
||||
echo '"a<a-P>a<ret><esc>gjd%<a-|><ret>'
|
||||
# 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>'
|
||||
else
|
||||
# paste all, select all, pipe to copy cmd
|
||||
echo '"a<a-P>%<a-|><ret>'
|
||||
fi
|
||||
}
|
||||
# clean up
|
||||
delete-buffer
|
||||
}
|
||||
}
|
||||
|
||||
define-command -docstring %{
|
||||
Copies selections to system clipboard, splitting each selection onto new lines.
|
||||
} clip-copy-split %{
|
||||
evaluate-commands -save-regs 'a|' %{
|
||||
execute-keys '"ay'
|
||||
edit -scratch
|
||||
set-register | %opt{clipboard_copy_cmd}
|
||||
execute-keys '"a<a-P>a<ret><esc>gjd%<a-|><ret>'
|
||||
delete-buffer
|
||||
}
|
||||
}
|
||||
|
||||
define-command -docstring %{
|
||||
Copies selections to system clipboard, does not split selections onto new lines.
|
||||
} clip-copy-verbatim %{
|
||||
evaluate-commands -save-regs 'a|' %{
|
||||
execute-keys '"ay'
|
||||
edit -scratch
|
||||
set-register | %opt{clipboard_copy_cmd}
|
||||
execute-keys '"a<a-P>%<a-|><ret>'
|
||||
delete-buffer
|
||||
}
|
||||
}
|
||||
|
||||
map -docstring "yank the selection into the clipboard" global user y "<a-|> wl-copy<ret>"
|
||||
map -docstring "yank the selections into the clipboard" global user y ": clipboard-copy<ret>"
|
||||
map -docstring "yank the split selections into the clipboard" global user Y ": clipboard-copy -split<ret>"
|
||||
|
||||
map -docstring "paste the clipboard" global user p "<a-!> wl-paste -n<ret>"
|
||||
map -docstring "paste the clipboard before" global user P "! wl-paste -n<ret>"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue