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 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/"?

share|improve this question
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
add comment

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).

share|improve this answer
2  
Meta + Backspace does the same too. –  hekevintran Mar 29 '10 at 8:29
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.