Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
    
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
add comment

3 Answers

up vote 10 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
    
Wow this may have changed how I use the terminal forever. Thanks! –  David Nov 30 '12 at 13:52
add comment

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
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
add comment

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
add comment

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.