1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-27 14:51:58 +00:00
ohmyzsh/plugins/dirhistory
2021-12-26 18:29:55 +01:00
..
dirhistory.plugin.zsh fix(dirhistory): define key bindings for vi mode (#10450) 2021-12-26 18:29:55 +01:00
README.md docs(dirhistory): document OPT key alternative for macOS and fix style 2021-11-02 15:12:43 +01:00

Dirhistory plugin

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)

Keyboard Shortcuts

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.

Usage

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 (/).