2024-08-09 09:44:46 +02:00
|
|
|
# per-directory-history plugin
|
2013-02-28 16:28:08 +01:00
|
|
|
|
2019-04-29 21:08:26 +02:00
|
|
|
This plugin adds per-directory history for zsh, as well as a global history,
|
|
|
|
and the ability to toggle between them with a keyboard shortcut. This is a
|
|
|
|
bundle of the [official plugin by @jimhester][5].
|
2013-02-28 16:28:08 +01:00
|
|
|
|
2019-04-29 21:08:26 +02:00
|
|
|
To use it, add `per-directory-history` to the plugins array in your zshrc file:
|
2013-02-28 16:28:08 +01:00
|
|
|
|
2019-04-29 21:08:26 +02:00
|
|
|
```zsh
|
|
|
|
plugins=(... per-directory-history)
|
|
|
|
```
|
2013-02-28 16:28:08 +01:00
|
|
|
|
2019-04-29 21:08:26 +02:00
|
|
|
This is an implementation of per-directory history for zsh, some implementations
|
|
|
|
of which exist in bash[1][],[2][]. It also implements a toggle-history function
|
|
|
|
to change from using the directory history to using the global history. In both
|
|
|
|
cases the history is always saved to both the global history and the directory
|
|
|
|
history, so the toggle state will not effect the saved histories. Being able to
|
|
|
|
switch between global and directory histories on the fly is a novel feature.
|
2013-02-28 16:28:08 +01:00
|
|
|
|
2019-04-29 21:08:26 +02:00
|
|
|
## Usage
|
2013-02-28 16:28:08 +01:00
|
|
|
|
2019-04-29 21:08:26 +02:00
|
|
|
The default mode is per directory history, interact with your history as normal.
|
2013-02-28 16:28:08 +01:00
|
|
|
|
2019-04-29 21:08:26 +02:00
|
|
|
Press ^G (the <kbd>Control</kbd> and <kbd>G</kbd> keys simultaneously) to toggle
|
|
|
|
between local and global histories. If you would prefer a different shortcut to
|
|
|
|
toggle set the `PER_DIRECTORY_HISTORY_TOGGLE` environment variable.
|
2013-02-28 16:28:08 +01:00
|
|
|
|
2019-04-29 21:08:26 +02:00
|
|
|
## Configuration
|
2013-02-28 16:28:08 +01:00
|
|
|
|
2019-04-29 21:08:26 +02:00
|
|
|
* `HISTORY_BASE` is a global variable that defines the base directory in which the
|
|
|
|
directory histories are stored (default `$HOME/.directory_history`).
|
|
|
|
* `per-directory-history-toggle-history` is the function to toggle between local
|
|
|
|
and global histories.
|
|
|
|
* `PER_DIRECTORY_HISTORY_TOGGLE` is the key binding used to run the toggle-history
|
|
|
|
function above (default `^G`)
|
2023-11-29 10:15:32 +01:00
|
|
|
* `PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE` is a variable which toggles whether
|
|
|
|
the current mode is printed to the screen following a mode change (default `true`)
|
2013-02-28 16:28:08 +01:00
|
|
|
|
2019-04-29 21:08:26 +02:00
|
|
|
## History
|
2013-02-28 16:28:08 +01:00
|
|
|
|
2018-08-07 20:42:02 +02:00
|
|
|
The idea/inspiration for a per directory history is from [Stewart MacArthur][1]
|
2019-04-29 21:08:26 +02:00
|
|
|
and [Dieter][2], the implementation idea is from [Bart Schaefer][3]. The
|
|
|
|
implementation is by [Jim Hester][4] in September 2012.
|
2013-02-28 16:28:08 +01:00
|
|
|
|
|
|
|
[1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
|
|
|
|
[2]: http://dieter.plaetinck.be/per_directory_bash
|
2018-08-07 20:42:02 +02:00
|
|
|
[3]: https://www.zsh.org/mla/users/1997/msg00226.html
|
2019-04-29 21:08:26 +02:00
|
|
|
[4]: https://jimhester.com
|
|
|
|
[5]: https://github.com/jimhester/per-directory-history
|