Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
1  
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
up vote 22 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.

share|improve this answer
    
Thanks, I think I'm going the standard way. – licorna Jun 13 '11 at 17:34
1  
Wow this may have changed how I use the terminal forever. Thanks! – David Nov 30 '12 at 13:52

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.

share|improve this answer
2  
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

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.

share|improve this answer

You can just use Alt-DEL instead of the normal Strg-DEL.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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