bindkey with zsh on Mac

2020-05-26 10:08发布

问题:

I've been trying to bind keys in zzh on a Mac but am having some trouble. I know I should be Googling this but couldn't find what I need...

I've been trying to bind ctrl-backspace to be an equivalent of ctrl-w, ie delete one word. But I can't find the key code for it. Nothing shows up when I do it with 'read'. I can't find a chart online either.

Also, I couldn't bind home/end keys (ie fn-left, fn-right) somehow. It is not bound in Terminal's keyboard assignments or .zshrc but it's still doing weird stuff when I press it. Page up and down seem to behave less strangely. Any help?

Thanks

回答1:

Open a shell and try pressing Ctrl-v and then the key you want to bind (eg. Home) This is the key sequence you should use with bindkey.

My bindings for Home/End (start/end of line) on Snow Leopard:

bindkey '^[[H' beginning-of-line
bindkey '^[[F' end-of-line

Still trying to bind cmd-left though ...