I finally have a very unstable version of this running on my laptop
Still needs a bunch of work, but right now it works something like this
Run atuin daemon somewhere. Leave it running
daemon.enable = true in config
Just use Atuin and it’ll send history over a unix socket, instead of writing sqlite directly.
SQLite is still read directly for the TUI, but the main goal here is to get disk access off of the hot path. Once that’s done, it can start to be used for some of the other things we discussed
I might be able to port the daemon to windows, it might need a separate script to run at startup to start the daemon thought (but that shouldn’t be a problem hopefully!)
@YummyOreo / @tessus That would be good, but please avoid it for now - the current implementation doesn’t include any such scripts, as it’s intended only for testing. I’d rather nobody use it seriously just yet.
Just run atuin daemon in the foreground somewhere for the time being
There’s also a whole bunch of discussion in this thread concerning the best way to start and run the daemon, but yes launchctl is an option for macos.
I’d like to put the socket file at $XDG_RUNTIME_DIR/atuin.sock. Could this be supported in some way? (i.e. use the same config file but works on different machines with different $XDG_RUNTIME_DIR.)
Forking on its own doesn’t seem good for me. Its stdout / stderr is lost (though you could redirect it elsewhere early). It can be killed because the session is over, or it won’t exit and some other process waits for it to finish (e.g. ssh).
A systemd.socket unit will be good to start it automatically without user interaction (like PulseAudio / PipeWire).
I’ve used the daemon for some days. It works pretty well, except when it is restarted. Not only the restart command is lost, but also all started but unfinished commands in other terminals too. Maybe the daemon could save the unfinished commands before exiting?
We wouldn’t have to download anything, that’s just how powerlevel10k does it with gitstatusd.
The daemon part could just be part of the regular atuin binary.
Communication with the daemon could happen via a private socket, and if no daemon is running, atuin could just spawn it and then have it run forever in the background or exit after a period of no activity.
It may not. And it may exit without a clue why it has exited (I have an auto-spawn daemon which exits randomly without any trace.)
It takes time. systemd user session does have this idea to close a session after a period of no activity, but nobody is going to wait for the session to close.
Yep definitely an issue atm, in-progress commands are just in memory. I think dumping them to some temp file would work, I’d rather avoid committing incomplete data to the database. I know that’s how the old implementation worked, but it was quite impure + had issues.