Is there a shortcut in bash and zsh to delete one component of a path? For example, if I type
ls ~/local/color/, and the cursor is at the end of line, is there a shortcut to delete the
color/ at the end? Ideally I want solutions in both vi-mode and emacs-mode
|show 1 more comment|
The most commonly used commands in the default bash emacs mode, for most commonly used keyboards:
By default bash (and I'm guessing zsh) will be in emacs-mode. You could try something like this:
Esc + b will put the cursor back one word. Ctrl + k will delete until the end of the line.
Most modern shells (like bash) will implement advanced command line editing features. Those commands are either close to emacs editing (Ctrl +A for line beginning, Ctrl + E for line end, ...).
If you're familar with vi-like editors, you could try to allow vi-mode.
It gives your shell vi-like modes (command mode/insert mode), and you get access to the standard commands (d for delete, r for replace, ...)
In Vi Mode, here's how you would do what you described: