Using Ctrl or Alt AND backspace to delete last word in Bash

Solution 1:

You can always use Ctrl-W. It deletes the word before the cursor and works in every Bash.

See here for a list of Bash keyboard shortcuts.

Solution 2:

You just need to set Option as Meta key in iTerm's preferences (Profiles » Keys).

backward-kill-word is bound to Meta-Rubout (i.e. Opt-Backspace) by default.

The same option exists (albeit less flexible) in Apple's Terminal.app.

Solution 3:

You can create a file .inputrc in your home directory and add this content inside:

"\C-h": backward-kill-word

Solution 4:

In terminator you can use the following "plugin", along with

[keybindings]
    kill_word = <Control>BackSpace

in your config file. This will map Ctrl-Backspace to ESCDEL, another shorcut to delete last word.