Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
originally posted at github.com/larkery/issues/137 Function to parse zsh's histfile and add it to the database. Leverages zsh's history file parsing so it handles newlines and arbitrary characters very well. The other tools suggested in the README require other languages and don't handle multiline commands soundly. Inserts are batched and it's pretty fast. A bit of time is wasted calling `fc -l` to read the timestamps, but it takes ~1s to parse ~20k lines for me so it should be fast enough for most use-cases. Notes: * this sets the `session` to `0` * (sqlite starts autoincrement ids at 1 so it shouldn't coincide with any actual histdb sessions) * `dir` is set to the empty string (`''`) instead of `NULL` because sqlite doesn't let you use `NULL` as part of a key * Added `unique(session, command_id, place_id, start_time) on conflict ignore` constraint to the `history` table so history instances are de-duped. * Useful for importing history file backups that likely contain dupes
- Loading branch information