docs: update readme

This commit is contained in:
Viktor Varland 2025-02-28 16:01:58 +01:00
parent 12ac4b86c2
commit f538b45e84
Signed by: varl
GPG key ID: 7459F0B410115EE8

View file

@ -1,30 +1,27 @@
# shell-history # shell-history
## setup
## zsh ## zsh
`~/.zshrc`: `~/.zshrc`:
``` ```
HISTDB="$HOME/dev/vlv/histdb" SHISTDB="$HOME/dev/vlv/histdb"
SHIST="$HOME/dev/vlv/shell-history" SHIST="$HOME/dev/vlv/shell-history"
autoload -Uz compinit promptinit add-zsh-hook autoload -Uz compinit promptinit add-zsh-hook
_history() { _history() {
if test "$(id -u)" -ne 0; then if test "$(id -u)" -ne 0; then
echo "$(date --utc --iso-8601=seconds) $(hostname) $(pwd) $(fc -ln -1)" >> \ echo "$(date --utc --iso-8601=seconds) $(hostname) $(pwd) $(fc -ln -1)" >> \
$HISTDB/zsh-history-$(date "+%Y-%m-%d").log; $SHISTDB/zsh-history-$(date "+%Y-%m-%d").log;
fi fi
} }
add-zsh-hook precmd _history add-zsh-hook precmd _history
_history-sync() { _history-sync() {
if [[ -d "$HISTDB" ]]; then if [[ -d "$SHISTDB" ]]; then
() { () {
pushd -q "$HISTDB" pushd -q "$SHISTDB"
source "$SHIST/sync.sh" source "$SHIST/sync.sh"
popd -q popd -q
} }