Partially delete path in zsh (Option + Backspace) In zsh Option + Backspace deletes the whole path on a prompt. For example:

ls /usr/local/bin


Option + Backspace returns:

ls


How can I set the same behavior so that the shortcut deletes just one word, till the next delimiter, like:

ls /usr/local/bin


Option + Backspace should return:

ls /usr/local/
An arbitrary number of alphabetic characters and digits as well as chars defined by WORDCHARS are considered all one word in zsh.

The default value of WORDCHARS is: 

% echo $WORDCHARS
*?_-.[]~=/&amp;;!#$%^(){}&lt;&gt;


By defining another/a new WORDCHARS in .zprofile (and/or .zshrc|... - depends on how you configured your zsh environment), you can modify the behaviour of werase (word erase - usually ctrl/^w).

Simply add the line export WORDCHARS='*?_-.[]~=&amp;;!#$%^(){}&lt;&gt;' in .zprofile|..., close the Terminal window or source .zprofile|... and werase  works as you want afterwards.

Keep in mind that other shortcuts (like alt/⌥←) will also be affected then.



If you want a different behaviour, check this question &amp; answer: zsh: using different WORDCHARS for kill-word and forward-word / backward-word