I set up my iTerm to work a lot like OSX does in other text fields, eg ⌘ Command+Delete = delete line backward, ⌥ Option+left arrow = "move cursor back one word" and ⌥ Option+Delete = delete word backward, but the way I have it, ⌥ Option+Delete in bash/iTerm doesn't count / as a word separator, so if I have cd a/path/to/a/folder and I hit ⌥ Option+Delete it deletes the whole path, instead of just folder.

How can I set it up so that ⌥ Option+Delete only gets rid of folder? I realize this might need a bash solution, or an iTerm solution, but I don't know which. Or maybe it needs both.

1 Answer 1


In order to get this to work, in iTerm preferences I had to set the key alt+backspace (or w/e you have it as) to map to these hex codes:

0x1B 0x08

If using zsh, add the following to .zshrc:

autoload -U select-word-style
select-word-style bash
  • I wanted to say thank you for this answer! Everyone had the first part, but I did not find the second part (the .zshrc) anywhere!
    – cdavid
    Commented Jan 5, 2023 at 0:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .