Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/babarot/zsh-history
A plugin for zsh history extended by golang, dealing it like SQL
https://github.com/babarot/zsh-history
go golang zsh zsh-plugin
Last synced: 3 months ago
JSON representation
A plugin for zsh history extended by golang, dealing it like SQL
- Host: GitHub
- URL: https://github.com/babarot/zsh-history
- Owner: babarot
- Archived: true
- Created: 2017-02-08T13:09:40.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-05T12:47:44.000Z (over 6 years ago)
- Last Synced: 2024-05-21T13:50:19.259Z (8 months ago)
- Topics: go, golang, zsh, zsh-plugin
- Language: Go
- Homepage:
- Size: 4.09 MB
- Stars: 84
- Watchers: 3
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: history.go
Awesome Lists containing this project
README
zsh-history
===========A plugin for zsh history extended by golang, dealing it like SQL
![](https://cl.ly/032Z0Y2Z0Q2v/c.gif)
## Features
- Fast and simple
- Searchable by SQL
- History searchable per directory
- etc...
- Can sub-string search (like [zsh-users/zsh-history-substring-search](https://github.com/zsh-users/zsh-history-substring-search))
- Automatically backup daily DB file like:```console
$ tree $ZSH_HISTORY_BACKUP_DIR
/Users/b4b4r07/.zsh/history/backup
`-- 2017
`-- 02
|-- 13.db
`-- 14.db
2 directories, 2 files
```## Installation
```console
$ 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:
```zsh
# 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`
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### Configurable
Located in `~/.config/zhist/config.toml`:
```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