Fork me on GitHub

Synchronising Zsh history over the Internet with Oh My Zsh and history-sync

19 April 2016 - Melbourne

Occasionally I’ve thought to myself:

“What was that complex command sequence I ran on my laptop when I was using it 2 hours ago?”

I’ve either had to wait until I’m in range of my laptop to check my shell history, or I have to remember to email myself the commands… None of these solutions are really helpful 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 synchronize my ZSH history over the Internet?”

In the projects 200+ plug-in base, not one plug-in achieves said functionality. And that’s why I quickly wrote history-sync.

The basic concept is:

  1. Encrypt $HOME/.zsh_history using GPG public key encryption on source computer
  2. Push encrypted zsh_history to a remote Git repository
  3. Pull encrypted zsh_history from said Git repository and decrypt on destination computer
  4. Merge decrypted zsh_history with $HOME/.zsh_history

All of this is achievable using history-sync’s alias commands:

Here’s an example of it’s use.