Skip to content

Enter private mode or stop retaining new history while retaining current history during an active session #7589

@etcusrvar

Description

@etcusrvar

I would like to know if this is currently possible, or if this is a feature that could be implemented.

I would like something similar to what I have implemented in zsh (Note: this does have some bugs, but it meets my wants for now.)

Fish supports private mode-- this allows you to start a new session without retaining history.
But you can't enter private mode after the session has started.
The fish_private_mode variable is read-only and can't be changed by the user or via script.

Fish supports set fish_history, setting it to an empty string, which means "history will not be stored at all".
But once set fish_history is called during an active session, all history in the current session is gone.

$ sh -c 'env HOME=$(mktemp -d) fish'
Welcome to fish, the friendly interactive shell
Type `help` for instructions on how to use fish
x@x /h/x> foo
fish: Unknown command: foo
x@x /h/x [127]> bar
fish: Unknown command: bar
x@x /h/x [127]> history
bar
foo
x@x /h/x> set fish_history
  # up arrow recalls nothing; `foo`,`bar`, and `history` are gone
x@x /h/x> history
x@x /h/x> 
  # up arrow now recalls `history`; `foo` and `bar` are gone

Also, the history variable is read-only and can't be changed by the user or via script.

I understand from the docs that "the most common use case for this feature is to avoid leaking private or sensitive history when giving a presentation." But this requires either starting a new session with no history, or losing current history if in the middle of a session.

I understand that set fish_history foo switches to a different "session"-- a different history and file. I like this feature and use it, in both fish and zsh (via different ZDOTDIR paths on startup). But this is a different use case.

I'm leaning toward something like #1156 (comment) before private mode was implemented in fish.
But before I try going down the path of copying and renaming and manipulating history files (as I currently do in zsh), I wanted to see if there was a better (or any) alternative.

What might work is simply allowing fish_private_mode to be changed.

fish, version 3.1.2
Linux 5.9.16 x86_64
xterm-256color

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions