57 lines
1.9 KiB
Text
57 lines
1.9 KiB
Text
# 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'
|
|
|
|
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 %{
|
|
evaluate-commands -save-regs 'a|' %{
|
|
execute-keys '"ay'
|
|
edit -scratch
|
|
set-register | %opt{clipboard_copy_cmd}
|
|
execute-keys %sh{
|
|
if [ ${#} = 1 ] && [ ${1} = '-split' ]; then
|
|
echo '"a<a-P>a<ret><esc>gjd%<a-|><ret>'
|
|
else
|
|
echo '"a<a-P>%<a-|><ret>'
|
|
fi
|
|
}
|
|
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 "paste the clipboard" global user p "<a-!> wl-paste -n<ret>"
|
|
map -docstring "paste the clipboard before" global user P "! wl-paste -n<ret>"
|
|
map -docstring "replace with the clipboard" global user R '"_d! wl-paste -n<ret>'
|
|
|