Resurrectable sessions possible? (Setting ATUIN_SESSION = $TERM_SESSION_ID?)

Hi!

Just installed Atuin and had hoped it would solve my problem with separating session history (per terminal window/tab) from global history. This works perfectly fine until I have to log out/reboot, thus restarting the terminal app. Both Terminal.app & iTerm.app will automatically resurrect the TERM_SESSION_ID. The default behavior of Terminal.app means that session–specific history will be available in resurrected windows after reboot.

Unfortunately it seems the AUTIN_SESSION is recreated upon each restart which means I lose all session-specific history on logout. I have searched the docs without finding any hints on how to achieve this.

I tried export ATUIN_SESSION = ${TERM_SESSION_ID} in .zshrc , which seems to actually work. Is this a recommended approach or will it mess with Atuin internals?

(zsh, MacOS Sequoia).

Thanks,

Mikael

1 Like

That won’t break anything! Feel free to do so

ATUIN_SESSION is reset whenever a new shell session begins, and we don’t really have awareness of the terminal session (and I’d rather avoid doing so, by default).

1 Like

Hi @ellie / anyone else. I would like the same behaviour being asked for, but when I set that in my .zshrc, it doesn’t work when using Mac Terminal restore terminal feature.
In my .zshrc:

. "$HOME/.atuin/bin/env"
eval "$(atuin init zsh)"
export ATUIN_SESSION=$TERM_SESSION_ID

I’ve tried moving the export to the start and end but still had no luck. Thanks.

I have it working in both Terminal.app & iTerm.app. Here’s what I do in .zshrc:

SESSION_UUID=$(echo ${TERM_SESSION_ID} | sed 's/.*://g')

export ATUIN_SESSION=${SESSION_UUID} # Not sure if this is the best place...
. "$HOME/.atuin/bin/env"
eval "$(atuin init zsh)"
export ATUIN_SESSION=${SESSION_UUID} # ... or this? Or both?

That first sed line is because iTerm adds some extra window/tab-prefixes on session id:s. It’s probably not needed if you just use Terminal.

1 Like

Thanks @Mikael. Setting ATUIN_SESSION at the start and end worked for me and should work for those just using Terminal.

export ATUIN_SESSION=${TERM_SESSION_ID}
. "$HOME/.atuin/bin/env"                                                                                                                                                                                         
eval "$(atuin init zsh)"
export ATUIN_SESSION=${TERM_SESSION_ID}