Allow fish_private_mode to change at runtime

Prior to this change, `fish_private_mode` worked by just suppressing
history outright. With this change, `fish_private_mode` can be toggled on
and off. Commands entered while `fish_private_mode` is set are stored but
in memory only; they are not written to disk.

Fixes #7590
Fixes #7589
This commit is contained in:
ridiculousfish
2021-01-01 13:57:45 -08:00
parent 9fdc4f903b
commit 118f710e99
6 changed files with 93 additions and 9 deletions

View File

@@ -90,7 +90,6 @@ static const std::vector<electric_var_t> electric_variables{
{L"_", electric_var_t::freadonly},
{L"fish_kill_signal", electric_var_t::freadonly | electric_var_t::fcomputed},
{L"fish_pid", electric_var_t::freadonly},
{L"fish_private_mode", electric_var_t::freadonly},
{L"history", electric_var_t::freadonly | electric_var_t::fcomputed},
{L"hostname", electric_var_t::freadonly},
{L"pipestatus", electric_var_t::freadonly | electric_var_t::fcomputed},
@@ -119,8 +118,7 @@ static bool is_read_only(const wcstring &key) {
if (auto ev = electric_var_t::for_name(key)) {
return ev->readonly();
}
// Hack.
return in_private_mode() && key == L"fish_history";
return false;
}
/// Return true if a variable should become a path variable by default. See #436.