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

Unable to import structured history data from hishtory into atuin and have the atuin program search it #2345

Open
1 task done
matthewcmead opened this issue Aug 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@matthewcmead
Copy link

What did you expect to happen?

I've been using https://github.com/ddworken/hishtory/ for global history capture and would like to migrate to atuin. I have been unable to find a way to import hishtory's structured history data into atuin in a way that atuin will use. Here's what I've done:

I've used clickhouse-local with the following SQL to transform the hishtory data to atuin's schema:

create database hishtory Engine = SQLite('.hishtory/.hishtory.db');
select distinct id, start_time timestamp, end_time-start_time duration, exit, command, cwd, id session, hostname, null deleted_at from (select lower(hex(MD5(concat(local_username, '//', hostname, '//', command, '//', current_working_directory, '//', start_time, '//', end_time)))) id, toUnixTimestamp64Nano(parseDateTime64BestEffort(start_time)) start_time, toUnixTimestamp64Nano(parseDateTime64BestEffort(end_time)) end_time, exit_code exit, command, current_working_directory cwd, hostname from hishtory.history_entries);

I then exported this to TSV, and used sqlite3 to load the history data into atuin's history.db file:

.mode tabs
.import history hishtory.tsv

I'm then able to see the entries in the sqlite table.

What happened?

I expected atuin to allow me to search these prior history entries, but it does not. Is there some mechanism to get atuin to sync all its internal data off the history.db history table and incorporate it future executions of the program?

Thanks!

Atuin doctor output

% atuin doctor
Atuin Doctor
Checking for diagnostics


Please include the output below with any bug reports or issues

{
  "atuin": {
    "version": "18.3.0",
    "sync": null,
    "sqlite_version": "3.44.0"
  },
  "shell": {
    "name": "zsh",
    "default": "zsh",
    "plugins": [
      "atuin"
    ],
    "preexec": "built-in"
  },
  "system": {
    "os": "Darwin",
    "arch": "arm64",
    "version": "14.5",
    "disks": [
      {
        "name": "Macintosh HD",
        "filesystem": "apfs"
      },
      {
        "name": "Macintosh HD",
        "filesystem": "apfs"
      }
    ]
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@matthewcmead matthewcmead added the bug Something isn't working label Aug 5, 2024
@ellie
Copy link
Member

ellie commented Aug 6, 2024

Hey!

history.db isn't meant to be written to externally. We have a central source (records.db) that stores history encrypted, ready to sync. If it's not added to records, it won't function properly. We have an import function that handles history from other sources, and ensures it's stored correctly.

I'd suggest one of the following

  1. Convert the format to something we support importing. Resh or zsh-histdb might be a good option. https://github.com/atuinsh/atuin/tree/main/crates/atuin-client/src/import
  2. If you're comfortable doing so, writing an importer specifically for hishtory would be amazing! I imagine it wouldn't be too hard to base off of an existing importer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants