MacOS – In iTerm, how can I change alt+delete to ignore slashes

bashitermkeyboardmacos

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.

Best Answer

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