Bash: delete word ahead of cursor

I answered similar question on unix.stackexchange.com:

Bash has readline commands that aren't bound by default. You can find them at reference: http://www.gnu.org/software/bash/manual/html_node/Bindable-Readline-Commands.html#Bindable-Readline-Commands

Command you are looking for is called "shell-backward-kill-word". You have to select shortcut first. Let's use Crtl+p, since it's "previous command" - same as up arrow.

bind '"\C-p": shell-backward-kill-word'

The only difference is you have to use "shell-kill-word" command instead, since you want to delete forward.

There is also a "kill-word" command with Meta+d shortcut (try Esc+d if you don't have Meta key). It will delete only one part of path at once.


Tested both the esc+d and alt/opt+d on OSX Mavericks and they work there as well.