shell-history/sync.sh

24 lines
421 B
Bash
Executable file

#!/bin/zsh
git add zsh-history-*.log
git commit --all --message "$(hostname): update history"
git pull --no-edit --no-rebase
for f in ./zsh-history-*.log; do
tmpfile=$(mktemp)
exec 3>"$tmpfile"
exec 4<"$tmpfile"
rm "$tmpfile"
grep --invert-match "^[<,>,=]\{5,\}" $f >&3
<&4 tee $f
sort --output="$f" "$f"
git add $f
git commit -m "$(hostname): resolve merge ${f}"
done
git push