A plugin for zsh history extended by golang, dealing it like SQL
-
Fast and simple
-
Searchable by SQL
- History searchable per directory
- etc...
-
Can sub-string search (like zsh-users/zsh-history-substring-search)
-
Automatically backup daily DB file like:
$ tree $ZSH_HISTORY_BACKUP_DIR /Users/b4b4r07/.zsh/history/backup `-- 2017 `-- 02 |-- 13.db `-- 14.db 2 directories, 2 files
$ git clone https://github.com/b4b4r07/zsh-history && cd zsh-history
$ make && sudo make install
$ source init.zsh
Set the env like the following:
# DB file path
export ZSH_HISTORY_FILE="$HOME/.zsh_history.db"
# CLI selector
export ZSH_HISTORY_FILTER="fzy:fzf:peco:percol"
# History per directory
export ZSH_HISTORY_KEYBIND_GET_BY_DIR="^r"
# All histories
export ZSH_HISTORY_KEYBIND_GET_ALL="^r^a"
# Run any SQLs on original selector I/F (with screen)
export ZSH_HISTORY_KEYBIND_SCREEN="^r^r"
# substring
export ZSH_HISTORY_KEYBIND_ARROW_UP="^p"
export ZSH_HISTORY_KEYBIND_ARROW_DOWN="^n"
Table name: history
Name | Type | Desc |
---|---|---|
id | int | ID |
date | string | Date time (format by %F %T ) |
dir | string | Direcotry when executed |
command | string | Command |
status | int | Status code ($? ) |
host | string | Host name |
Located in ~/.config/zhist/config.toml
:
prompt = "sqlite3> "
init_query = "SELECT DISTINCT(command) FROM history WHERE command LIKE '%%' AND status = 0 ORDER BY id DESC"
init_cursor = "%"
vim_mode_prompt = "VIM-MODE"
ignore_words = [
"false",
"echo",
]
MIT
b4b4r07