6

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

3

1 Answer 1

4

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

1
  • 2
    Meta + Backspace does the same too. Mar 29, 2010 at 8:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .