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
  • 2
    Good answer. For anyone else coming here using zsh, you'll also want to add autoload -U select-word-style select-word-style bash to your ~/.zshrc Jan 4, 2019 at 18:48
  • 5
    For anyone trying to update their .zshrc the above suggestion from @PeterDolan is actually two separate commands: autoload -U select-word-style and select-word-style bash Jun 3, 2021 at 21:16
  • I feel HermanJ.RadtkeIII's answer should be accepted.
    – lkahtz
    Jun 14, 2021 at 11:17

You must log in to answer this question.

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