Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmatic import #2431

Open
pawamoy opened this issue Oct 22, 2024 · 4 comments
Open

Programmatic import #2431

pawamoy opened this issue Oct 22, 2024 · 4 comments

Comments

@pawamoy
Copy link

pawamoy commented Oct 22, 2024

So I have been using my own history tool for quite some time now, and have 220K+ commands in a file (+ other backed up files from other machines), in a custom format, that I'd like to import in Atuin 🙂

How would I go about feeding Atuin programmatically, since surely the import subcommand will not support my history file format? You can assume I have all the necessary fields (and more 😄).

@pawamoy
Copy link
Author

pawamoy commented Oct 22, 2024

Hmmm I guess I could simply check the database schema and insert things in it directly ^^

@ellie
Copy link
Member

ellie commented Oct 22, 2024

It's not quite that simple I'm afraid. We actually have two databases, and it's important to ensure that data is copied across them properly.

  1. records.db: this stores your shell history data encrypted, on disk. It's used for syncing cross-machine, and is not at all editable manually
  2. history.db: this contains your actual shell history data, in a format we can search and browse

I'd first disable auto-sync if you've already set it up. auto_sync = false in your config file.

There is a command that will take the data from history.db, and insert it into records.db. Once you've inserted to history.db, run:

atuin history init-store

This should be idempotent, and the process may happen automatically at sync time.

Once complete, I'd issue

atuin store rebuild history

This will wipe out history.db, and rebuild it from the records.db. Just to make sure everything is consistent!

Then, run

atuin sync

You should be good to go from here, and can re-enable auto_sync.

@ellie
Copy link
Member

ellie commented Oct 22, 2024

also - love all the graphs from your tool!

@pawamoy
Copy link
Author

pawamoy commented Oct 22, 2024

Awesome, thank you so much for the clear instructions! I'll try that and report back 🙂

also - love all the graphs from your tool!

Thanks! I believe you have everything you need to offer similar graphs in Atuin too 😄 I could actually consider contributing if that's something you're interested in ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants