phiresky / ts-histdbimport

Imports a `.zsh_history` file into a https://github.com/larkery/zsh-histdb sqlite database.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Imports a .zsh_history file into a zsh-histdb sqlite database.

Like go-histdbimport, but 6000x faster.

Usage

Make sure you have node installed, then run

npx histdbimport

Alternatively, get the source from this repo and run it from here:

git clone https://github.com/phiresky/ts-histdbimport
cd ts-histdbimport
npm install
npm run insert-all

Will import ~/.zsh_history into ~/.histdb/zsh-history.db.

You can set env vars to change the input / output filename:

$ history_file=zh database=x.db npm run insert-all

Benchmark

Importing a history file with 299k entries:

  • go-histdbimport: 9.08 inserts/s (would take 9 hours)
  • ts-histdbimport: 56500 inserts/s (5.29s total)

With (#3) it should be even faster, though it now uses more memory. Thanks @Adk9p!

About

Imports a `.zsh_history` file into a https://github.com/larkery/zsh-histdb sqlite database.


Languages

Language:JavaScript 100.0%