dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

backup-zsh-history (333B)


      1 #!/bin/sh
      2 HIST="$HOME/.config/zsh/.zsh_history"
      3 BACKUPDIR="$HOME/.config/zsh"
      4 TIMESTAMP="$(date "+%F_%T")"
      5 
      6 if [ -s "$HIST" ]; then
      7   zstd < "$HIST" > "$BACKUPDIR/zsh_history_$TIMESTAMP.zstd"
      8 fi
      9 # find . -type f -name 'zsh_history_*.zstd' -exec stat --printf '%Y %n\0' {} \; | sort -znr | sed -zn '3,${s/[^ ]\+ //; p}' | xargs -0 rm