Is there a reliable way to programmatically determine whether a given machine is already logged into an atuin sync server or not?
I’m trying to make my “new machine bootstrapping” script idempotent, so I have a lot of if brew_formula_not_installed; then brew install $formula; fi code to skip redundant commands, and I’m struggling to find the best way to handle this for atuin’s sync login.
Re-running atuin login -u myuser -p mypass -k mykey (values passed in from 1Password’s op cli tool though) on an already-logged-in system produces an error message and exits with 1, so my working approach right now is to just always run the login and swallow the stderr output, but this feels sub-optimal.
In my dream world, my code could look like this:
if ! atuin --quiet logged_in; then
atuin login -u myuser -p mypass -k mykey
fi
The goal being an atuin command that prints whether it’s logged in already or not (but that output can be silenced– or swallowed to /dev/null, I suppose), and critically returns a comparable exit code (0/1 for logged in/out, or vice-versa, whatever.) That command could take a lot of forms too, of course;
atuin sync --statusatuin login --statusatuin status sync –quiet
The exact theoretical syntax is irrelevant to the question though. Am I overlooking something that already exists? Perhaps even if [ -f "$HOME/.local/share/atuin/key" ] might approximate it, but doesn’t guarantee the login is functional.
Thanks for your time and attention!