16 Jul 2026
histsync: sync shell history with pass
Atuin is super cool: it let's you sync shell history across machine, but few issues for me:
- Requires a server. I distrust managed public servers and don't want to host my own.
- Heavy LLM usage for development. I have nothing against LLMs but I try to avoid them.
I use password-store (pass), so why don't I leverage this:
bash = {
enable = true;
# ...
initExtra = ''
histsync() {
# Append currently history to HISTFILE
history -a
# Entry name in pass - I separate history by host
local passentry="ShellHistories/$HOSTNAME"
# Merge HISTFILE and pass entries, remove duplicates, update HISTFILE
(cat "$HISTFILE" 2>/dev/null; pass show "$passentry" 2>/dev/null) |
awk '!a[$0]++' |
${pkgs.moreutils}/bin/sponge "$HISTFILE"
# Update pass entry with the merged history
<"$HISTFILE" pass insert -mf "$passentry"
# Reload history for current session
history -c
history -r
}
# ...
'';
};
Note: the merge logic will not work if you use timestamps.
Tags: