In Linux I'm used to press Ctrl-Backspace to delete the last word but I don't know how to do it in Bash terminal.

In OS X I use Alt-Backspace to do the same thing.

Is there any way of making Bash recognize the Ctrl- or Alt-Backspace key combination to delete last word?

In Linux I use terminator as terminal emulator, in OSX I use iTerm2.

link|improve this question

Alt-⌫ a.k.a. Alt-← a.k.a. Alt-Backspace works perfectly fine for me. I'm using Terminator 0.93. – Teddy Jun 14 '11 at 9:49
feedback

2 Answers

up vote 4 down vote accepted

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.

link|improve this answer
Thanks, I think I'm going the standard way. – licorna Jun 13 '11 at 17:34
feedback

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.

link|improve this answer
1  
Actually, you have to use the "+Esc" setting. Only setting it to "acts as: Meta" results in ? being printed instead of the word getting deleted. – slhck Jun 13 '11 at 17:32
@slhck Not for me. But since the developers recommend it anyway, it can't be a bad thing. – Daniel Beck Jun 13 '11 at 17:34
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.