Live data from Hacker News

Atuin replaces your existing shell history with a SQLite database

github.com

121–130 of 198 posts

Re: Atuin replaces your existing shell history with a SQLite database

#121

It looks like it's not possible to export the history to a format the shell can import[0], so if I wanted to try this out, my commands would be locked there. It looks interesting, so if I'm overlooking a way to do this with fish, I'd experiment with it. [0]: https://github.com/ellie/atuin/issues/816

You can use sqlite[0] to export the database, or if you want a ui, use datasette[1]. On my mac, the database is stored at ~/.local/share/atuin/history.db

[0] https://sqlite.org/cli.html#export_to_csv [1] https://docs.datasette.io/en/stable/csv_export.html

Re: Atuin replaces your existing shell history with a SQLite database

#122

Earlier quoted context omitted.

Ah, a fellow packrat! I have every command I ever typed into a shell since around 2005, and my history weighs in at 1 CD or 650MB (as of a couple of years ago) I'm probably being wasteful of space because I store each session in a separate file. I used to do a lot of data analysis at the shell back in the day, and found it useful to audit sequences of commands afterwards for mistakes, or to turn them into scripts.

This is so insane that I love it. Do you also save your belly button lint since 2005? Or nail clippings? :)

I'm only a digital packrat. Bits are so much cheaper to hoard, even deciding to throw something away is often more work.

Re: Atuin replaces your existing shell history with a SQLite database

#123
post #96
post #6

What's it like with many shells/panes in multiplexers open? I often find my history from one or another either lost or not available across different ones.

You can get that with bash with this config: # append to .bash_history and reread after each command export PROMPT_COMMAND="history -a;$PROMPT_COMMAND" # append to .bash_history instead of overwriting shopt -s histappend

Except that this doesn't save commands which haven't finished yet, and it never saves the current pending command when the shell is killed (e.g. the user closes the terminal window or logs out or the SSH connection is broken).

Sometimes the rare, long-running commands are the most valuable.

If I set up history software, it should preserve all history, and as early as possible.

Re: Atuin replaces your existing shell history with a SQLite database

#124

Earlier quoted context omitted.

Ah, a fellow packrat! I have every command I ever typed into a shell since around 2005, and my history weighs in at 1 CD or 650MB (as of a couple of years ago) I'm probably being wasteful of space because I store each session in a separate file. I used to do a lot of data analysis at the shell back in the day, and found it useful to audit sequences of commands afterwards for mistakes, or to turn them into scripts.

Do you regularly back up your history?

Oh yes. It gets backed up along with everything else.

Re: Atuin replaces your existing shell history with a SQLite database

#125

Earlier quoted context omitted.

Grep only works if you want an exact string match. If you want to find words out of order or support features like stemming, fts is necessary.

Maybe I have some sort of disease, but while reading "find words out of order or support features like stemming" the regexs for that immediately flashed before my eyes, so I think "necessary" is a little strong there.

FTS is not the same as regex.

Re: Atuin replaces your existing shell history with a SQLite database

#126

Earlier quoted context omitted.

Oh, we don't actually delete anything - just deduplicate for search. Sequential context is something we're building very soon. The idea: you search for "cd /project/dir", press TAB and it opens up a new pane in the tui. This will show the command +/- 10 commands. You can then navigate back in time. This could indeed be useful for managing that one setup command you always have to run in this project dir but never rem…

> Oh, we don't actually delete anything - just deduplicate for search. Good to hear, but the point stands: so you deduplicate only for the view, not in the source, and thus the source remains contaminated with duplicates (at very least they cost some disk space and increase seek time). As for the view: so, since you deduplicate the commands - you can't lookup the context (commands executed before & after)! Because ea…

As the sqlite schema below indicates, each command has a unique id and a timestamp. Whether you want duplicates removed depends on what you want to know. It might be nice for the UI to expose a time context, which would retain duplicates. (Maybe it does! By coincidence, I just installed this yesterday, and I hardly know anything.)

CREATE TABLE history ( id text primary key, timestamp integer not null, duration integer not null, exit integer not null, command text not null, cwd text not null, session text not null, hostname text not null, deleted_at integer,

unique(timestamp, cwd, command) ); CREATE INDEX idx_history_timestamp on history(timestamp); CREATE INDEX idx_history_command on history(command); CREATE INDEX idx_history_command_timestamp on history( command, timestamp );

Re: Atuin replaces your existing shell history with a SQLite database

#127
post #15

> Atuin replaces your existing shell history with a SQLite database How can that work. Nobody is going to pay any ransom for just a shell history, and there are ways to get it out of a SQLite database. Wouldn't it be simpler just to encrypt the original .bash_history?

I think the advantage of the sqlite database is that you retain more context for any given command (e.g. what the current working directory was, ...) in a structured way (it is a database after all). That stored context can then be used to query the database (e.g. filter the history to only show commands that were executed in the cwd). These queries are the point of using sqlite, not anything security as far as I can…

I just don't see how sqlite is up to this; the problem clearly requires PostgreSQL.

Re: Atuin replaces your existing shell history with a SQLite database

#130

I made a script that uses atuin to get previous commands related to your current command line - latest commands ran in the same session, in the same directory, in other sessions, latest commands for the same executable etc. then feeds it into GPT and streams the replies to fzf so you can choose the best autocompletion (or it can fix problems in the line you've written already as well). On Wezterm and Kitty it can als…

Well it's published. Wasn't ready to publish and didn't have time to clean it up but I'll get back to it in the coming days, there's also some extra features on the way but disabled currently. Works quite well for me though.

https://github.com/TIAcode/LLMShellAutoComplete

Forgot to add needs tiktoken, openai and fzf. If someone knows how to do that command line query and replace on other than fish/nushell, please let me know.

Post reply on HN