Open theottm opened 1 year ago
I haven't tested it at all but this could work for M-w
_kill_ring_save(){
zle .copy-region-as-kill
printf "%s" "${CUTBUFFER}" | osc-copy
zle .neg-argument 1
zle .set-mark-command
}
zle -N kill-ring-save _kill_ring_save
bindkey '^@' .set-mark-command
bindkey '\ew' kill-ring-save
Use any clipboard manager like pbcopy or xclip instead of osc-copy in my example
_kill_region_to_clip() {
if ((REGION_ACTIVE)); then
zle .copy-region-as-kill
osc-copy "${CUTBUFFER}"
zle .kill-region
else
zle .set-mark-command
zle .backward-word
zle .exchange-point-and-mark
zle .copy-region-as-kill
pbcopy "${CUTBUFFER}"
zle .backward-kill-word
fi
zle .set-mark-command -n -1
}
zle -N kill-region-to-clip _kill_region_to_clip
bindkey '^@' .set-mark-command
bindkey '^w' kill-region-to-clip
You can use this for C-w, it kills the word backwards if there isn't a region but kills the region if there is. If you want the same behavior without killing you can leave out the kill-region and backward-kill-word and bind the result to '\ew'
I am looking for
M-w
andC-w
to work directly in the prompt (ouside ofcopy-mode
), similar to howC-k
can kill the line using the workaround here : https://github.com/akermu/emacs-libvterm/issues/304#issue-605130255If I understand correctly, currently the mark is not set when doing
C-SPC
, but instead the command is directly send to vterm sinceC-SPC
is bound tovterm--self-insert
.So one would need to add the mark somehow and then define something like
vterm-send-M-w
which would do something like the above mentioned issue.