atuin icon indicating copy to clipboard operation
atuin copied to clipboard

Do not save commands when the user unsets HISTFILE/HISTSIZE/HISTFILESIZE

Open uber6 opened this issue 2 years ago • 4 comments

Admins often unset HISTFILE, HISTSIZE, and/or HISTFILESIZE when certain strings must be used with commands. However with atuin initialized, atuin save all commands the use enters. A smart feature should be added where when the user unsets one of those variables, atuin discards all commands used in that same session.

uber6 avatar Jan 25 '23 03:01 uber6

We had a plan for an ephemeral storage session at some point. Eg atuin ephemeral could launch a subshell and temporarily fork the local database copy so you still have access to your history, but it won't sync and it will be deleted as soon as you run exit.

Although actually saving these history items is a bit sketch because we can't guarantee that they will be deleted. In theory we could have a separate in memory background process but now this is feature creep.

The simplest suggestion I have for now is exploiting the space-prefix explicit ignore feature.

conradludgate avatar Jan 25 '23 07:01 conradludgate

Please not at the level of the raw public interface for programs/scripts.

I would be profoundly annoyed if I had to go out of my way to export a dummy HISTFILE value from a REPL/editor that never uses it when calling out to atuin.

Endorsed at the shell integration level (with the caveat that I endorse it because we're already in a world where shells already have this interface, and it's nice to be a drop-in replacement).


By the way, in bash (by default) and zsh (with the histignorespace option), and maybe other shells, you don't need to unset the history variables, you can just type a space at the front of a command to stop it from going into history (the "the space-prefix explicit ignore feature" mentioned in the previous comment).

mentalisttraceur avatar Apr 15 '23 03:04 mentalisttraceur

@conradludgate ephemeral sessions might not be necessary to make users with this need happy.

I am guessing that the main use case here

  1. user has really strong habit of unsetting the history variable instead of putting a space at the front of their command line (maybe they've been doing this for decades and it's such muscle memory that it's out of the way to unlearn it, maybe they still have to use shells where the space thing doesn't work)
  2. user is totally fine with the command immediately disappearing even from session history, becoming totally irretrievable in any way right after they hit enter.

(When I think back to every time I've used the space-prefix feature, I've almost never needed to review or rerun the command within the same session.)

mentalisttraceur avatar Apr 15 '23 03:04 mentalisttraceur

We already don't log history in fish when in private mode, a similar change could be suggested for the other shells: https://github.com/atuinsh/atuin/blob/4096bb8d175170dd0bcc2918a4f733bc1d233cfd/atuin/src/shell/atuin.fish#L3-L7

It would be quite an easy change to the init scripts.

We had a plan for an ephemeral storage session at some point. Eg atuin ephemeral could launch a subshell and temporarily fork the local database copy so you still have access to your history, but it won't sync and it will be deleted as soon as you run exit.

That sounds complicated. I'd just set ATUIN_SESSION to a special token, hide it by default unless you're in that session and provide a command to clear it. And since deletion has been implemented it becomes a bit easier too. I'll consider writing that up actually...

arcuru avatar Oct 27 '23 07:10 arcuru