# Goal: better multi-selection behavior # If we copy multiple selections, it should be copied s.t. each selection is on its own line declare-option -docstring %{ Command for copying to system clipboard } str clipboard_copy_cmd 'wl-copy' define-command -params 0..1 clip-copy %{ evaluate-commands %sh{ if [ ${#} = 1 ] && [ ${1} = split ]; then echo "clip-copy-split" else echo "clip-copy-verbatim" fi } } 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 execute-keys '"aagjd%%opt{clipboard_copy_cmd}' 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 execute-keys '"a%%opt{clipboard_copy_cmd}' delete-buffer } } map -docstring "yank the selection into the clipboard" global user y " wl-copy" map -docstring "paste the clipboard" global user p " wl-paste -n" map -docstring "paste the clipboard before" global user P "! wl-paste -n" map -docstring "replace with the clipboard" global user R '"_d! wl-paste -n'