veronika: add readme and scripts
This commit is contained in:
commit
12ac4b86c2
33
README.md
Normal file
33
README.md
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# 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
|
||||
}
|
||||
```
|
||||
23
sync.sh
Executable file
23
sync.sh
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/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
|
||||
Loading…
Reference in a new issue