? How to run Fish Shell in private mode on Linux

Fish Shell comes with a lot of cool features by default.

One such feature is private mode.

In this quick tutorial, we’ll see how to run Fish Shell in private mode on Linux to avoid storing commands in the history file

In other words, we’ll see how to enable incognito mode in the Fish shell.

As you already know, nothing is logged in incognito mode.

Shell history file

Every Unix shell has the ability to log all the commands you run in your Terminal. Depending on the shell used, the commands are stored in a text file elsewhere. In the Bash shell, all commands are written to the ~ / .bash_history file by default. In the Fish shell, command records are stored in the ~ / .local / share / fish / fish_history file. In the Zsh shell, commands are saved in ~ / .zsh_history or any other user-configured file. Now the question is, what if you don’t want to record command history at all? Perhaps you are using a shared system and do not want to save the commands you run in the history file. If you’ve ever wanted to stop logging commands in the history file, we’ll show you how you can do this below.

Launching Fish Shell in private mode on Linux

Since version 3.0, the fish shell comes with the –private flag, which you can use to launch the Fish shell in private or incognito mode.

To enable incognito mode in this shell, simply start it with the –private flag, as shown below:

                        $ fish --private

When you run Fish in private mode, it displays a notification as shown in the following output:

                        Welcome to fish, the friendly interactive shell
Type `help` for instructions on how to use fish.
fish is running in private mode, history will not be persisted.

You are now in a private fish shell session!

In private mode, the old history is not available, and any interactive commands you execute will not be added to the global history file, making it useful both for preventing inadvertent leakage of personal information (for example, for screencasts) and when dealing with sensitive information to prevent it saved to disk.

Note that the Fish shell does not add whitespace commands to its history file by default.

The –private flag makes this work even easier.

The system will not record command history while the user remains in private mode.

To return to normal mode, type exit and start fish shell again without the –private flag.

Related Posts