You and the shell seem to have different ideas on which characters are parts of a word and which aren't.
For zsh
, you should read chapter 4.3.4: Words, Regions and Marks of the zsh
User Guide. Depending on which editing mode you're using, you might be able to get what you want by manipulating the $WORDCHARS
variable (it contains a list of non-alphanumeric characters that should also be considered parts of a word).
(Disclaimer: I don't know much about current versions of zsh
and especially not of oh-my-zsh
. My job takes me to many systems, often stripped-down to the minimum required, some with fancy configurations; so I've got used to working with "plain vanilla" shell configuration. I have a fairly minimal set of shell customizations I might set up on systems I visit often, but I can live without them if necessary; I understand many professional sysadmins generally end up with shell configurations like that eventually.)
For bash
, if your "delete last word" keystroke is associated to readline
library function backward-kill-word
(as by default), it considers only letters and numbers as word components; any other characters will separate words from each other.
In bash
version 4.0 and newer, there should be an alternative readline
function named shell-backward-kill-word
, which might suit your needs better.See this question for more details.
Ctrl + W
works correctly on my bash, butOpt + Delete
is the same bad as zsh – ssppjj May 25 '23 at 17:16