Home Fish shell How To Launch Fish Shell In Private Mode In Linux
Enable incognito mode in Fish shell in Linux

How To Launch Fish Shell In Private Mode In Linux

By sk
348 Views

Fish shell ships with many cool features by default. One such feature is Private Mode. In this brief guide, we will see how to launch Fish shell in private mode in Linux to avoid storing commands in history file. In other words, we will see how to enable incognito mode in Fish shell. As you know already, nothing gets logged in incognito mode.

Shell history file

Every Unix shell has the ability to log all commands that you've run in your Terminal. Depends upon the shell you use, the commands are stored in a text file in different location. In Bash shell, all commands are logged to ~/.bash_history file by default. In Fish shell, the command entries are stored in ~/.local/share/fish/fish_history file. In Zsh shell, the commands are saved in ~/.zsh_history or any other file configured by the user.

Now the question is what if you don't want to record the command history at all? May be you are using a shared system and don't want to save the commands you run in the history file. If you ever wanted to stop logging the commands in the history file, here is how you can do it.

Launch Fish Shell In Private Mode In Linux

Starting from version 3.0, the fish shell comes with --private flag that can be used to start fish shell in private or incognito mode.

To enable incognito mode in fish shell, simply start it with --private flag like below:

$ fish --private

When you start fish in private mode, it will display 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.
Launch Fish Shell In Private Mode In Linux
Launch Fish Shell In Private Mode In Linux

Now you are inside a private fish session! In private mode, old history is not available and any interactive commands you execute will not be appended to the global history file, making it useful both for avoiding inadvertently leaking personal information (e.g. for screencasts) and when dealing with sensitive information to prevent it being persisted to disk.

Please note that Fish shell does not append commands with a space into its history file by default. The --private flag makes this job even easier. It won't record the command history as long as the user stays in the private mode. To go back to the normal mode, type exit and start the fish shell again without --private fag.

For more details, refer fish man page:

man fish

You know now what is private mode in fish shell and how to launch fish shell in private or incognito mode to prevent the commands from being logged in the history file. Hope this was useful.

Related read:

You May Also Like

3 comments

Jalal December 2, 2020 - 3:35 pm

Hi,

Nice….
Thanks a lot…

Reply
Marshall Neill December 11, 2020 - 10:01 am

If you precede the command with a ‘space’ it won’t be stored; am I right?

Reply
sk December 11, 2020 - 11:13 am

Yes.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More