diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index 0b0ba7e47..e2164f00d 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -36,6 +36,11 @@ function __fish_config_interactive -d "Initializations that should be performed set -U fish_greeting "$line1$line2" end + if set -q fish_private_mode + set -l line (_ "fish is running in private mode, history will not be persisted.") + set -g fish_greeting $fish_greeting.\n$line + end + # # If we are starting up for the first time, set various defaults. # diff --git a/src/env.cpp b/src/env.cpp index 84a229636..ba7627dc7 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -296,7 +296,8 @@ bool string_set_contains(const T &set, const wchar_t *val) { /// Check if a variable may not be set using the set command. static bool is_read_only(const wchar_t *val) { - const string_set_t env_read_only = {L"PWD", L"SHLVL", L"history", L"status", L"version", L"fish_pid", L"hostname", L"_"}; + const string_set_t env_read_only = {L"PWD", L"SHLVL", L"history", L"status", L"version", + L"fish_pid", L"hostname", L"_", L"fish_private_mode"}; return string_set_contains(env_read_only, val) || (in_private_mode() && wcscmp(L"fish_history", val) == 0); } diff --git a/src/history.cpp b/src/history.cpp index 81240feab..d96ffefdc 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1992,6 +1992,7 @@ static bool private_mode = false; void start_private_mode() { private_mode = true; env_set_one(L"fish_history", ENV_GLOBAL, L""); + env_set_one(L"fish_private_mode", ENV_GLOBAL, L"1"); } bool in_private_mode() {