保存 zshell 的目录特定历史记录

Save Directory Specific history for zshell

我正在尝试保存我的目录特定的命令行历史记录。 AKA,当我在一个名为 Happy 的目录中并向上箭头时,我不想查看我过去的所有命令行历史记录,我只想查看在特定 Happy 目录中完成的历史记录。

我还希望将所有这些都保存到一个文件中,以便我以后可以访问它。也许将它保存到按目录或按日期组织的文件中,我不知道什么是最好的。有人有这样的设置吗?

谢谢!

听起来您可以在 GitHub 上使用此脚本。自述文件摘录:

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.