zsh: stop backward-kill-word on directory delimiter

前端 未结 3 437
清酒与你
清酒与你 2021-01-30 08:36

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
<         


        
相关标签:
3条回答
  • 2021-01-30 08:51

    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).

    0 讨论(0)
  • 2021-01-30 09:01

    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='*?_-.[]~=&;!#$%^(){}<>'
    
    0 讨论(0)
  • 2021-01-30 09:15

    A quick google reveals:

    Backward Kill

    Or, perhaps a better fix:

    Bash Style Backward Kill

    0 讨论(0)
提交回复
热议问题