A CLI to provide enhanced history for your shell
- Submatch & Fuzzy search
- Share the history among multiple machines
- Easy to customize with the config file in TOML
- Run immediately when just selecting command on the screen via interactive filters
- Customizable what information as a column is displayed on the screen line
- Filter the directory and/or branch that the command was executed
- Text database based on LTSV
- Automatically backup
- and more...
-
Get binaries
- via GitHub Releases: https://github.com/b4b4r07/history/releases
- for Gophers:
go get -u github.com/b4b4r07/history
-
(Additional) if you're zsh user, it's better to intergrate your shell
$ git clone https://github.com/b4b4r07/history && cd history $ source misc/zsh/init.zsh
You should specify some enviroment variables for using this tool.
ZSH_HISTORY_KEYBIND_GET
You can set keybind for getting history.
Example:
export ZSH_HISTORY_KEYBIND_GET="^r"
export ZSH_HISTORY_FILTER_OPTIONS="--filter-branch --filter-dir"
In fact, when you invoke that keybind (in this example, ^r
), the following command will be executed and supplemented to your ZLE (on shell).
command history search $ZSH_HISTORY_FILTER_OPTIONS --query "$LBUFFER"
If you set ZSH_HISTORY_FILTER_OPTIONS
like above, it's equals to $ZSH_HISTORY_KEYBIND_GET
's function behavior.
ZSH_HISTORY_FILTER_OPTIONS
It should be set history search
option. See also command history help search
.
ZSH_HISTORY_KEYBIND_GET_BY_DIR
It's equals to $ZSH_HISTORY_KEYBIND_GET
with ZSH_HISTORY_FILTER_OPTIONS="--filter-branch --filter-dir"
.
ZSH_HISTORY_KEYBIND_GET_ALL
Ignore ZSH_HISTORY_FILTER_OPTIONS
and search all history.
Example:
export ZSH_HISTORY_KEYBIND_GET_ALL="^r^a"
ZSH_HISTORY_COLUMNS_GET_ALL
Specify the screen column when displaying with ZSH_HISTORY_KEYBIND_GET_ALL
Defaults to "{{.Time}},{{.Status}},{{.Command}},({{.Base}}:{{.Branch}})"
ZSH_HISTORY_KEYBIND_ARROW_UP
Example:
export ZSH_HISTORY_KEYBIND_ARROW_UP="^p"
ZSH_HISTORY_KEYBIND_ARROW_DOWN
Example:
export ZSH_HISTORY_KEYBIND_ARROW_DOWN="^n"
ZSH_HISTORY_AUTO_SYNC
Example:
export ZSH_HISTORY_AUTO_SYNC=true
If you set sync option (for more datail, see and run history config
)
ZSH_HISTORY_AUTO_SYNC_INTERVAL
Example:
export ZSH_HISTORY_AUTO_SYNC_INTERVAL="1h"
Anyway, if you want to use it immediately please copy and paste the following into your zshrc
:
alias hs="command history" # as you like
ZSH_HISTORY_KEYBIND_GET="^r"
ZSH_HISTORY_FILTER_OPTIONS="--filter-branch --filter-dir"
ZSH_HISTORY_KEYBIND_ARROW_UP="^p"
ZSH_HISTORY_KEYBIND_ARROW_DOWN="^n"
and invoke that zle function with typing Ctrl-R after reloading your zsh, of cource ;)
For more info and customization, see also wiki pages in this project:
https://github.com/b4b4r07/history/wiki
MIT
b4b4r07