39 lines
656 B
Markdown
39 lines
656 B
Markdown
# shell-history
|
|
|
|
## zsh
|
|
|
|
```
|
|
cd $HOME/dev/vlv
|
|
git clone git.meatbag.se:vlv/shell-history.git shell-history
|
|
mkdir histdb
|
|
```
|
|
|
|
`~/.zshrc`:
|
|
|
|
```
|
|
autoload -Uz compinit promptinit add-zsh-hook
|
|
|
|
histdb_dir="$HOME/dev/vlv/histdb"
|
|
histcmd_dir="$HOME/dev/vlv/shell-history"
|
|
|
|
_add_history() {
|
|
if test "$(id -u)" -ne 0; then
|
|
echo "$(date --utc --iso-8601=seconds) $(hostname) $(pwd) $(fc -ln -1)" >> $histdb_dir/zsh-history-$(date "+%Y-%m-%d").log;
|
|
fi
|
|
}
|
|
add-zsh-hook precmd _add_history
|
|
|
|
hsup() {
|
|
() {
|
|
source $histcmd_dir/sync.sh "$histdb_dir"
|
|
}
|
|
}
|
|
|
|
hs() {
|
|
() {
|
|
source $histcmd_dir/search.sh "$histdb_dir" "$@"
|
|
}
|
|
}
|
|
|
|
```
|