Skip to content
Advertisement

Save Directory Specific history for zshell

I am trying to save my directory specific command line history. AKA, when I am in a directory called Happy, and I arrow up, I don’t want to see all of my past command line history, I only want to see the history that was done in the specific Happy directory.

I also want all of this to get saved to a file so that I can access it later. Perhaps save it to files organized by directory, or by date, I don’t know what would be best. Does anyone have anything like this set up?

Thank you!

Advertisement

Answer

It sounds like you could use this script on GitHub. Excerpt from README:

Per-Directory-History

Per directory history for zsh, as well as global history, and the ability to toggle between them with ^G.

This is a implementation of per directory history for zsh, some implementations of which exist in bash. It also implements a per-directory-history-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 as far as I am aware.

This is a standalone repository for the script, however it is also included in oh-my-zsh as a plugin.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement