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.
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
For more details, refer
fish man page:
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.