How to delete one directory level in a command argument (up to a slash) on ZSH command line?

3

1

I just switched from bash to zsh. One thing that is different and a bit annoying from me that Alt-Backspace removes the whole argument instead of just one word. I'm used to using it to remove one level of directory in a file path on the command line. Is there a keystroke for zsh that I could use instead?

Petr Pudlák

Posted 2014-01-04T12:58:34.057

Reputation: 2 197

Answers

3

This is a frequently asked question, see e.g.

However, some answers seem to be outdated (contribution to the mailing list dating back to 2001) or rather complicated.

In the easiest case (and answering your specific question to delete back to a slash) I'd boil it down to

autoload -Uz select-word-style
select-word-style bash

As always with zsh you can, but sometimes also have to do much more customization if it does not suit your needs out of the box. Because I'm no expert for select-word-style (I've written my own widgets for that purpose), please refer to man zshcontrib for a detailed explanation of the options.

mpy

Posted 2014-01-04T12:58:34.057

Reputation: 20 866

1

The default combination working for me is CTRL + w

noggerl

Posted 2014-01-04T12:58:34.057

Reputation: 1 229

What is STRG? Next to the ANY key? – Kevin Panko – 2014-01-04T21:37:57.103

sorry, just edited, forgot that this is the german name for the key – noggerl – 2014-01-05T11:17:36.380