-
-
Notifications
You must be signed in to change notification settings - Fork 601
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
Add history export (and re-import) option, machine-readable #816
Comments
You might know we already have a sync service. This uses JSON already, but the payloads are encrypted. In theory we could have a cli version too. But it needs a proper design. We have some ideas on the roadmap. I'll see if we can fit this in with our new ideas too. Thanks for the suggestion |
"Workaround" script (nushell, but you get the point): atuin search -c $session_dir --format '"command": "{command}", "directory": "{directory}", "duration": "{duration}", "user": "{user}", "host": "{host}", "time": "{time}", "exit": "{exit}", "relativetime": "{relativetime}"'
| str trim | each {|s| '{' + $s + '}'} # = surround with curly braces
| save "export.jsonl" # save to jsonl file (note: can't put |
Here's a little script I'm using to keep my Atuin history synced with my Nushell history. I run it to both import and to sync when I delete items from history. The only reason I sync Atuin and Nushell is just because I like those ZSH-style autocompletions as you type, which as far as I know Atuin only currently natively supports for ZSH itself. # Remember to change the DB paths to your own.
echo "\
ATTACH DATABASE '/home/tombh/.local/share/atuin/history.db' AS atuin;\
DELETE FROM history;\
INSERT INTO history(command_line, start_timestamp, hostname, cwd, duration_ms, exit_status) \
SELECT command, timestamp, hostname, cwd, duration, exit FROM atuin.history;\
" | sqlite3 ~/.config/nushell/history.sqlite3 |
It could be a useful addition to atuin to offer history export, reimport/merge in a machine-readable, open, stable format.
I did find the SQLite database in ~/.local/share/atuin, but that's "locked away" in a sense, IMHO, requiring SQLite tooling.
Using JSON as data exchange format, it would be possible to
atuin history list --json
, sitting next to the--format
optionatuin history replace --json < my-history.json
atuin history append --json < my-history.json
atuin history list --json | jq ' <fancy-filtering-here> ' | atuin history append --json
This would be particularly useful in scenarios where there is no Atuin server around, only sneakernet.
Disclaimer: I only just installed
atuin
, with one major attraction being the global shell history across bash sessions (something thatfzf
does not / cannot offer).The text was updated successfully, but these errors were encountered: