Tags All Entries


Useful usage

  • histdb-top will show the most commonly used commands

Installing zsh-histdb in zprezto

mkdir $ZPREZTODIR/contrib
git clone https://github.com/larkery/zsh-histdb $ZPREZTODIR/contrib/zsh-histdb

Add zsh-histdb in zstyle ‘:prezto:load’ in zpreztroc file:

--- a/zsh/zpreztorc
+++ b/zsh/zpreztorc
@@ -27,6 +27,7 @@ zstyle ':prezto:load' pmodule \
   'environment' \
   'terminal' \
   'editor' \
+  'zsh-histdb' \
   'history' \
   'directory' \
   'spectrum' \

For macOS add this line before modules are sourced, I chose right above the zstyle line in zpretorc:

HISTDB_TABULATE_CMD=(sed -e $'s/\x1f/\t/g')

Importing existing commands

npx histdbimport

Setting up sync

zsh-histdb uses git to synchronize commands across machines. This is pretty handy as you can pull up commands used elsewhere. The initial setup is a bit finicky and I made mistakes, my recommended approach would be to start by running the sync command on the machine with the most command history (maybe use import above). It will initialize a git repo. Now manually you should setup the remote repo in ~/.histdb (recommended the remote be private!), and re-run sync, you know have your main branch. On each subsequent machine copy your .histdb directory to a backup location. Run sync to setup the git repo at .histdb, manually setup the remote and pull down. Copy your db from your backup into .histdb, run sync again and it will handle the merge.

Links to this note