In Bash, Ctrl + W will erase the last word. Bash considers words to be delimited by spaces.

This means that if the cursor is at the end of the string "cd /dir1/dir2/dir3" and you hit Ctrl + W you will be left with "cd ".

Is there a Bash shortcut (custom defined is okay) that will leave me with "cd /dir1/dir2/"?

link|improve this question

73% accept rate
1  
possible duplicate: superuser.com/questions/113103/… .. also see questions listed at superuser.com/questions/tagged/bash+keyboard-shortcuts .. do any of those answer your question? – quack quixote Mar 29 '10 at 3:17
1  
note with standard bash keys, you can do this with Meta+B then Ctrl+K (move-backward-word then cut-to-end-of-line); from superuser.com/questions/113103/… – quack quixote Mar 29 '10 at 3:40
feedback

1 Answer

up vote 3 down vote accepted

Try pressing Esc, then Ctrl-H (or Esc, then Backspace) which should be bound to backward-kill-word (and you could bind to something else).

link|improve this answer
2  
Meta + Backspace does the same too. – hekevintran Mar 29 '10 at 8:29
feedback

Your Answer

 
or
required, but never shown

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