Home

Awesome

zsh-history

A plugin for zsh history extended by golang, dealing it like SQL

Features

Installation

$ git clone https://github.com/b4b4r07/zsh-history && cd zsh-history
$ make && sudo make install
$ source init.zsh

Usage

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"

About zhist

Schema

Table name: history

NameTypeDesc
idintID
datestringDate time (format by %F %T)
dirstringDirecotry when executed
commandstringCommand
statusintStatus code ($?)
hoststringHost name

Configurable

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",
]

License

MIT

Author

b4b4r07