I'm using answers from this question so that I can cut longer/shorter parts of text when I press Ctrl+W or Alt+Backspace respectively. Specifically I have this in my .zshrc
to add the Alt+Backspace behavior (Ctrl+W is built-in)
backward-kill-dir () {
local WORDCHARS=''
zle backward-kill-word
}
zle -N backward-kill-dir
bindkey '^[^?' backward-kill-dir
This works fine for killing text, but then pasting it doesn't work as expected. Let's say I have this text:
A quick brown fox
If I press Ctrl+W four times and then press Ctrl+Y, the entire text will be cut and then pasted back. But if I have this text:
a-quick-brown-fox
and I press Alt+Backspace four times and then Ctrl+Y, it will cut the text as expected but only paste
a-
How can I make the latter also paste the entire text?