29 votes

Atuin - SQLite-based shell history

19 comments

  1. [10]
    FluffyKittens
    (edited )
    Link
    Atuin is a cool little utility that stores shell history to a SQLite db. It also stores timestamp, return code, and runtime on top of the command text itself. Additionally, it offers the opt-in...

    Atuin is a cool little utility that stores shell history to a SQLite db. It also stores timestamp, return code, and runtime on top of the command text itself.

    Additionally, it offers the opt-in option to sync history across machines (E2EE OOTB, and self-hostable). Haven't tried this out yet, but if anyone does, I'd love to hear how it goes.

    I've been using it for a few weeks now, and it's been my favorite piece of software that I've added to the toolkit in years. It's already saved me hours of effort in terms of having to look up or double-check rsync/ssh/pg_dump/openssl/git/ripgrep/jq/etc. flags that I use frequently, yet not often enough to have 100%-verbatim committed to memory.

    Only gripes: Not a fan of the curl ... | bash install path, but the installer is well-written and easy enough to self-audit by curl -oing before running. There was a ~1-2 hour learning curve of adjusting to the new up-arrow behavior, but that's also easy to reconfigure to another key if desired.

    E: I set up the self-hosted sync server this weekend. The process was extremely smooth and user-friendly, as far as self-hosting goes.

    9 votes
    1. [5]
      ellie
      (edited )
      Link Parent
      Maintainer here! Thank you for sharing Atuin! Love to hear that you like it <3 You might like to try the enter_accept option we introduced in v17, which might feel a bit more natural.

      Maintainer here! Thank you for sharing Atuin! Love to hear that you like it <3

      There was a ~1-2 hour learning curve of adjusting to the new up-arrow behavior

      You might like to try the enter_accept option we introduced in v17, which might feel a bit more natural.

      11 votes
      1. FluffyKittens
        Link Parent
        Thanks for making it, and glad to see you on here! I appreciate the suggestion, though the default up-arrow behavior has now won me over pretty hard :).

        Thanks for making it, and glad to see you on here!

        I appreciate the suggestion, though the default up-arrow behavior has now won me over pretty hard :).

        2 votes
      2. [3]
        Bwerf
        Link Parent
        Hi, I hope this is ok to ask here in this old thread, but I'm having a some problems, I've installed it on two machines running ubuntu 22.04.3, and on one of those machines it doesn't record new...

        Hi, I hope this is ok to ask here in this old thread, but I'm having a some problems, I've installed it on two machines running ubuntu 22.04.3, and on one of those machines it doesn't record new input until I manually run atuin import auto. I'm using fairly standard install with bash as my shell on both machines. On the machine that gave me problems the install script didn't work either, so I manually installed the .deb and added initialization to my .bashrc. As far as I can tell everything else works as it should.

        1. [2]
          ellie
          Link Parent
          hey! totally ok, though I'm more likely to respond quickly on either the forum or discord! (https://forum.atuin.sh / https://discord.gg/Fq8bJSKPHh) did you follow the advanced setup docs?...

          hey! totally ok, though I'm more likely to respond quickly on either the forum or discord! (https://forum.atuin.sh / https://discord.gg/Fq8bJSKPHh)

          did you follow the advanced setup docs? https://atuin.sh/docs/advanced-install#bash

          Unfortunately bash doesn't provide shell hooks out of the box, so we also required users to install a plugin that provides this. BLE is the best bet, though it's more than just hooks. If you don't want BLE, bash-preexec is a good option.

          Otherwise:

          the install script didn't work either

          This is an issue :/ Do you have any more information?

          1. Bwerf
            (edited )
            Link Parent
            Weird, adding to history automatically is working on my other computer. Looks like I had bash-preexec installed as a side-effect of something else I've done earlier. As for the failed install,...

            Weird, adding to history automatically is working on my other computer. Looks like I had bash-preexec installed as a side-effect of something else I've done earlier.

            As for the failed install, this is what the output looks like. To do it manually I downloaded the script and modified to show the deb, then I downloaded and installed the deb manually, which worked. Then I edited my .bashrc to match what I had on my other computer.

            user:~$ bash <(curl https://raw.githubusercontent.com/ellie/atuin/main/install.sh)
              % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                             Dload  Upload   Total   Spent    Left  Speed
            100  6341  100  6341    0     0  21498      0 --:--:-- --:--:-- --:--:-- 21568
             _______  _______  __   __  ___   __    _
            |   _   ||       ||  | |  ||   | |  |  | |
            |  |_|  ||_     _||  | |  ||   | |   |_| |
            |       |  |   |  |  |_|  ||   | |       |
            |       |  |   |  |       ||   | |  _    |
            |   _   |  |   |  |       ||   | | | |   |
            |__| |__|  |___|  |_______||___| |_|  |__|
            
            Magical shell history
            
            Atuin setup
            https://github.com/atuinsh/atuin
            
            Please file an issue if you encounter any problems!
            
            ===============================================================================
            
            Detected Linux!
            Checking distro...
            Ubuntu detected
              % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                             Dload  Upload   Total   Spent    Left  Speed
              0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
            100 5146k  100 5146k    0     0  3707k      0  0:00:01  0:00:01 --:--:-- 5868k
            [sudo] password for user: 
            Reading package lists... Done
            E: Unsupported file /tmp/tmp.pQbZA5TN2g.deb given on commandline
            
    2. [4]
      Greg
      Link Parent
      I’d be interested to know how it’s changed your workflow? I use the shell history constantly, so I’m excited for anything that can improve that, but so far I don’t think the use case here has...

      I’d be interested to know how it’s changed your workflow? I use the shell history constantly, so I’m excited for anything that can improve that, but so far I don’t think the use case here has clicked for me - at least on a single dev machine. I could see it more if I had a need for continuous history between something ephemeral like k8s instances, but those aren’t something I’m regularly running commands on directly.

      For context, my current solution is SAVEHIST=1000000 with history 0 | grep foo pretty well in muscle memory now!

      3 votes
      1. unkz
        (edited )
        Link Parent
        I’m not a user yet but I can see how this would be handy when I’ve got a dozen tmux panes open. edit: I'm a user now, and it's pretty cool. Just the ctrl-r integration makes it worthwhile IMO --...

        I’m not a user yet but I can see how this would be handy when I’ve got a dozen tmux panes open.

        edit: I'm a user now, and it's pretty cool. Just the ctrl-r integration makes it worthwhile IMO -- being able to see a filterable, interactive list of all the commands I have recently run is awesome.

        4 votes
      2. FluffyKittens
        (edited )
        Link Parent
        I've always been a big history | grep user too. The biggest enhancements in my book are all on the UX side: the default UI shows if a command ran successfully based on color coding, how long ago...

        I've always been a big history | grep user too.

        The biggest enhancements in my book are all on the UX side: the default UI shows if a command ran successfully based on color coding, how long ago you ran it, and how long it ran for. It's presented in a style that's extremely easy to parse, and makes it much easier to remember what you were doing a few days ago + infer why you'd made some minor tweak to that command.

        History is automatically synced across terminal sessions that are currently open in realtime, which avoids bash's usual overwrite-on-exit behavior without having to mess with the usual history -a; history -c; history -r incantation.

        There's a hotkey to toggle between filtering history by current directory, host, and session. I've found the directory toggle awesome for quickly pulling up build and maintenance commands based on the repo root I'm in.

        The maintainers have made it clear that the local DB schema isn't guaranteed to be stable, but you can also pull up and query command history directly in Sqlite. Used it twice so far; once to scrub a credential I accidentally pasted and once to fuzzy search for a command I was having trouble finding.

        E: And the update-as-you-type behavior is a solid improvement over rerunning history | greps.

        3 votes
      3. zoroa
        Link Parent
        I haven't used this, but I recently started using fzf and its shell integration which lets you replace the default history substring search with fuzzy history search. It has been one of my...

        I haven't used this, but I recently started using fzf and its shell integration which lets you replace the default history substring search with fuzzy history search.

        It has been one of my favorite updates to my config, since it provides a powerful, convenient, and pleasant to use interface for search.

        From reading the docs, atuin sounds like it offers all of that and more.

        2 votes
  2. [3]
    Neko
    Link
    Been using it for quite a while now and it's definitely useful. Atuin allows me to quickly pull up any command that I may have used months ago. That being said I've found it to be quite slow when...

    Been using it for quite a while now and it's definitely useful. Atuin allows me to quickly pull up any command that I may have used months ago. That being said I've found it to be quite slow when pulling up its dashboard for the first time. There's a significant lag before I can actually start interacting with the history. So I had to fallback to Fish's <C-R> history, though I still have atuin recording my commands.

    FWIW there's other similar programs like mcfly and hishtory(https://github.com/ddworken/hishtory). mcfly uses a local neural engine to suggest you commands from history. Noticeably faster than atuin. Haven't used hishtory but looks similar to atuin but with not as many features.

    4 votes
    1. [2]
      ellie
      Link Parent
      What version are you using? Shouldn't be the case :/

      That being said I've found it to be quite slow when pulling up its dashboard for the first time. There's a significant lag before I can actually start interacting with the history

      What version are you using? Shouldn't be the case :/

      2 votes
      1. Neko
        Link Parent
        Looks like I'm on 16.0.0

        Looks like I'm on 16.0.0

        2 votes
  3. [3]
    fxgn
    Link
    Unless you're often running the same commands on different servers, what advantage does this have over just using the built-in shell history?

    Unless you're often running the same commands on different servers, what advantage does this have over just using the built-in shell history?

    3 votes
    1. [2]
      Bauke
      Link Parent
      Although I haven't tried it out yet, a potential use-case for me is being able to have a synced history between my regular shell (ZSH) and nix-shell (which uses Bash). I've run into it enough...

      Although I haven't tried it out yet, a potential use-case for me is being able to have a synced history between my regular shell (ZSH) and nix-shell (which uses Bash). I've run into it enough times where I'm looking for a command with reverse search only to realize I'm never gonna find it because I'm in Bash.

      4 votes
      1. Bauke
        Link Parent
        A little update, gave it a shot yesterday and so far it's working great. Getting it setup for ZSH and Bash was as simple as adding the initialization to both configs. One hiccup I've encountered...

        A little update, gave it a shot yesterday and so far it's working great. Getting it setup for ZSH and Bash was as simple as adding the initialization to both configs.

        One hiccup I've encountered so far is that there is no way to remove things from the history (relevant issue), but since it uses SQLite it's easy enough to open the database file and manually run a delete query.

        2 votes
  4. [2]
    untagged1328
    Link
    I have been using it for a while, and I like it. But I haven't yet figured out how to delete some unwanted / typing mistake entries, etc. I hope there is an easy way to do it.

    I have been using it for a while, and I like it. But I haven't yet figured out how to delete some unwanted / typing mistake entries, etc. I hope there is an easy way to do it.

    2 votes
    1. FluffyKittens
      Link Parent
      Unless it’s changed in the past 1-2 releases, deleting entries still hasn’t been smoothly implemented through CLI yet. The best route is to crack open the sqlite DB and manually run a DELETE....

      Unless it’s changed in the past 1-2 releases, deleting entries still hasn’t been smoothly implemented through CLI yet.

      The best route is to crack open the sqlite DB and manually run a DELETE. Happy to post instructions if you’re not familiar.

      1 vote
  5. [2]
    Comment removed by site admin
    Link
    1. ellie
      Link Parent
      Until you register, it's totally offline. So it can be reconfigured at any point there. Also, the server is hosted by hetzner in Frankfurt. You don't even need to register if you don't want to....

      It's not clear to me if you could set up self hosting /before/ all your data goes Whoosh to the USA

      Until you register, it's totally offline. So it can be reconfigured at any point there. Also, the server is hosted by hetzner in Frankfurt. You don't even need to register if you don't want to.

      PostgreSQL, which is a bit more resource usage than sqlite

      The current default is indeed postgres, but there's a SQLite option maintained here: https://github.com/conradludgate/atuin-server-sqlite

      Which is going to become the default in v18, as discussed here: https://github.com/atuinsh/atuin/discussions/1161

      Trust me bro promises on encryption again there

      Alternatively, you could trust the code. Which is open source, and we even have a blog post detailing how the new version will work.

      So in summary:

      1. You can use it without sync, by default.
      2. You can host your own server
      3. It won't reach out to the server unless you register and ask it to
      4. The free servers are in frankfurt
      5. You don't have to take my word for it, it's open source

      Are there any other concerns?

      16 votes