simple multi-computer shell history
Find a file
2025-02-28 16:00:41 +01:00
README.md veronika: add readme and scripts 2025-02-28 16:00:41 +01:00
sync.sh veronika: add readme and scripts 2025-02-28 16:00:41 +01:00

shell-history

setup

zsh

~/.zshrc:

HISTDB="$HOME/dev/vlv/histdb"
SHIST="$HOME/dev/vlv/shell-history"
autoload -Uz compinit promptinit add-zsh-hook

_history() {
    if test "$(id -u)" -ne 0; then
        echo "$(date --utc --iso-8601=seconds) $(hostname) $(pwd) $(fc -ln -1)" >> \
            $HISTDB/zsh-history-$(date "+%Y-%m-%d").log;
    fi
}
add-zsh-hook precmd _history

_history-sync() {
    if [[ -d "$HISTDB" ]]; then
        () {
            pushd -q "$HISTDB"
            source "$SHIST/sync.sh"
            popd -q
        }
    fi
}