Marc Cornellà e9bc107ad5 fix(dirhistory): define key bindings for vi mode (#10450) | 2 years ago | |
---|---|---|
.. | ||
README.md | 3 years ago | |
dirhistory.plugin.zsh | 2 years ago |
This plugin adds keyboard shortcuts for navigating directory history and hierarchy.
To use it, add dirhistory
to the plugins array in your zshrc file:
plugins=(... dirhistory)
Shortcut | Description |
---|---|
Alt + Left | Go to previous directory |
Alt + Right | Go to next directory |
Alt + Up | Move into the parent directory |
Alt + Down | Move into the first child directory by alphabetical order |
For macOS: use the Option key (⌥) instead of Alt.
NOTE: some terminals might override the Alt + Arrows key bindings (e.g. Windows Terminal). If these don't work check your terminal settings and change them to a different keyboard shortcut.
This plugin allows you to navigate the history of previous working directories using Alt + Left and Alt + Right. Alt + Left moves to past directories, and Alt + Right goes back to recent directories.
NOTE: the maximum directory history size is 30.
You can also navigate directory hierarchies using Alt + Up and Alt + Down. Alt + Up moves to the parent directory, while Alt + Down moves into the first child directory found in alphabetical order (useful to navigate long empty directories, e.g. Java packages).
For example, if the shell was started, and the following commands were entered:
cd ~
cd /usr
cd share
cd doc
the directory stack (dirs -v
) would look like this:
$ dirs -v
0 /usr/share/doc
1 /usr/share
2 /usr
3 ~
then entering Alt + Left at the prompt would change directory from /usr/share/doc
to /usr/share
,
then if pressed again to /usr
, then ~
. If Alt + Right were pressed the directory would be changed
to /usr
again.
After that, Alt + Down will probably go to /usr/bin
if bin
is the first directory in alphabetical
order (depends on your /usr
folder structure). Alt + Up will return to /usr
, and once more will get
you to the root folder (/
).