zsh: stop backward-kill-word on directory delimiter

ぐ巨炮叔叔 提交于 2019-12-20 08:27:40

问题


In zsh, how can I set up the line editor such that backward-kill-word stops on a directory separator? Currently in my bash setup, if I type

cd ~/devel/sandbox

and then hit C-w point will be right after "devel/". In my zsh setup, point would be after "cd ". I'd like to set up zsh so it behaves similarly to bash.


回答1:


A quick google reveals:

Backward Kill

Or, perhaps a better fix:

Bash Style Backward Kill




回答2:


For recent versions of zsh, you can simply add:

autoload -U select-word-style
select-word-style bash

to your zshrc as described in zshcontrib(1).




回答3:


Another option is to set WORDCHARS (non-alphanumeric chars treated as part of a word) to something that doesn't include /.

You can also tweak this if you'd prefer ^w to break on dot, underscore, etc. In ~/.zshrc I have:

WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'


来源:https://stackoverflow.com/questions/444951/zsh-stop-backward-kill-word-on-directory-delimiter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!