#shell-history #history #shell #sqlite

app shi_history

A tiny program to add the time and place to your shell history. This also enables you to copy a command to the clipboard.

5 releases (breaking)

new 0.7.0 Dec 30, 2024
0.6.0 Apr 7, 2024
0.5.0 Dec 3, 2023
0.4.0 Dec 2, 2023
0.3.2 Apr 23, 2023

#2552 in Command line utilities

Download history 2/week @ 2024-09-25 7/week @ 2024-10-02 1/week @ 2024-10-09 1/week @ 2024-12-04 4/week @ 2024-12-11 112/week @ 2024-12-25

117 downloads per month

MIT license

65KB
554 lines

shi

shell history / 史

A tiny program to add the time and place to your shell history.
This also enables you to copy a command to the clipboard.

screenshot.png

Installation

Sqlite required.

cargo install shi_history, or

git clone https://git.sr.ht/~kyoheiu/shi
cd shi
cargo install --path .

And add the preexec hook to your shell config file.

bash

(bash-preexec required. See https://github.com/rcaloras/bash-preexec)

source ~/.bash-preexec.sh
preexec() { shi --insert "$@"; }

Others

For zsh or fish, you can use preexec hook.

Option

If you'd like to copy a command to the clipboard, set any clipboard utility such as xclip or wl-copy as $SHI_CLIP.

Usage

At the first launch, shi creates sqlite database in $XDG_DATA_HOME/shi/.history (on Linux, in most case it should be ~/.local/share/shi/.history).

shi                              Print latest commands (50 rows)
shi <COMMAND> [ROWS]             Show commands that match the query

Options:
  -a, --all                      Print all the history with the directory path where the command was executed
  -i, --insert <COMMAND>         Insert the command to the history
  -r, --remove <ID>              Delete the command that matches the id
  -p, --path <PATH> [ROWS]       Show commands that were executed in directories that match the query
  -o, --output                   Export all the history to `$XDG_DATA_HOME/shi/history.csv`
  --drop                         Drop the database table, deleting all history

Dependencies

~3–10MB
~104K SLoC