How I integrate kakoune with wayland clipboard

Because I used wayland clipboard so often in kakoune, I created user mode shortcuts to handle wayland clipboard in kakoune.

map -docstring 'paste wayland clipboard after cursor' global user \
'p' '<a-!>wl-paste -n<ret>'
map -docstring 'paste wayland clipboard before cursor' global user \
'P' '!wl-paste -n<ret>'
map -docstring 'replace selections with wayland clipboard' global user \
'R' '|wl-paste<ret>'
map -docstring 'copy last selection to wayland clipboard' global user \
'y' '<a-|>wl-copy<ret>'

You might be interested in the RegisterModified hook described on the Registers & Clipboard page of the wiki.

I want distinction between clipboard and register.

Hi timber, how about something like:
printf 'wl-copy --paste-once --trim-newline
printf 'wl-paste --no-newline

added to lenormf’s out-of-the-box:

also a script in the form:

( wl-copy --paste-once --trim-newline $@ && sleep 10s && wl-copy --clear & ) 2>/dev/null
# and
( wl-paste --no-newline && wl-copy --clear ) 2>/dev/null

I just used wayland to do all that from kakoune, hope it helps. :wave:

That’s suitable for storing a password temporarily in a clipboard.

I don’t need to clear clipboard after a while or after pasting once.

Thanks screwtape, giving it a read now.

On the above page a community member has a plugin kakboard check it out as may provide you with some ideas or additional guidance on clipboard and registers.

I like clean separation of register from system clipboard. They do not mix at all in my kakrc.