Deleting input back to the last forward slash

I think you're looking for the Alt+Backspace shortcut.

After pressing Up this should delete back to the previous / or space character.


To detect the readline binding that kill a word backward as you wish you can use the following command in your terminal:

bind -p | awk '/kill/ && /word/ && /backward/'

In a default Ubuntu installation, the output could be:

"\e\C-h": backward-kill-word
# shell-backward-kill-word (not bound)

The second line seems without importance at this point, so let's try to see what means first line. From what I understand, the backward-kill-word readline function which in fact delete all characters untill the previous special character (/, ;, , etc.) is bound to the \e\C-h key sequence. Now, in this sequence \e represents the Esc key, \C - the Ctrl key, and \C-h stands for Ctrl+h which is equivalent in this case with Backspace key.

So, you are searching for Esc+Ctrl+h keyboard shortcut which is equivalent with Esc+Backspace and which, because of xterm's behaviour that make Alt key to act as a meta character and meta characters are converted into a two-character sequence with the character itself preceded by Esc (see man xterm), is equivalent with Alt+Backspace.

Now, if you don't like it and you continue to forget it, you can use the following command to create a new shortcut, let say Esc+w, for your purpose:

bind '"\ew": backward-kill-word'

To make this new shortcut persistent all the time for all commands that uses readline, add the following line line to your ~/.inputrc file:

"\ew": backward-kill-word

See help -m bind | sensible-pager for more info.