Synchronising Zsh history over the Internet with Oh My Zsh and history-sync
Occasionally I think to myself:
“What was the complex command sequence I ran on my laptop when I was using it 2 hours ago?”
When this happens, I either wait until I’m in range of my laptop to check my shell history, or I have to remember to record the commands, usually by sending an email to myself. None of these solutions is beneficial when I’m in a jam.
That’s why I thought to myself:
“Why doesn’t Oh-My-Zsh have such a plug-in, where I can synchronise my ZSH history over the Internet?”
In the project’s 200+ plug-in base, not one plug-in achieves said functionality. So, that’s why I wrote history-sync.
The basic concept is:
- Encrypt $HOME/.zsh_history using GPG public key encryption on the source computer
- Push encrypted zsh_history to a remote Git repository
- Pull encrypted zsh_history from said Git repository and decrypt on the destination computer
- Merge decrypted zsh_history with $HOME/.zsh_history
All of this is achievable using history-sync’s alias commands:
zhps -r <string> -r <string> -r ...
Here’s an example of its use.Tweet