Add a --private option to launch fish in private mode

In private mode, access to previous history is blocked and new history
does not persist and is only available for the duration of the current
session.

This mode can be used when it is not desirable for commandline history
to leak into a session, e.g. via autocomplete or when it is desirable to
test the behavior of fish in the absence of history items without
permanently clearing the history.

I'm sure there are a lot more features that can be incorporated into
private mode, such as restricting access to certain user-specific
configuration files, etc.

This addresses a lot of the concerns raised in #1363 (which was later
changed to track mosh-specific problems). See also #102.
This commit is contained in:
Mahmoud Al-Qudsi
2018-09-19 18:56:08 -05:00
committed by Fabian Homborg
parent b427cd1823
commit 379f44fabe
4 changed files with 24 additions and 2 deletions

View File

@@ -218,7 +218,7 @@ int run_command_list(std::vector<std::string> *cmds, const io_chain_t &io) {
/// Parse the argument list, return the index of the first non-flag arguments.
static int fish_parse_opt(int argc, char **argv, fish_cmd_opts_t *opts) {
static const char * const short_opts = "+hilnvc:C:p:d:f:D:";
static const char * const short_opts = "+hPilnvc:C:p:d:f:D:";
static const struct option long_opts[] = {{"command", required_argument, NULL, 'c'},
{"init-command", required_argument, NULL, 'C'},
{"features", required_argument, NULL, 'f'},
@@ -228,6 +228,7 @@ static int fish_parse_opt(int argc, char **argv, fish_cmd_opts_t *opts) {
{"login", no_argument, NULL, 'l'},
{"no-execute", no_argument, NULL, 'n'},
{"profile", required_argument, NULL, 'p'},
{"private", no_argument, NULL, 'P'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}};
@@ -283,6 +284,10 @@ static int fish_parse_opt(int argc, char **argv, fish_cmd_opts_t *opts) {
g_profiling_active = true;
break;
}
case 'P': {
start_private_mode();
break;
}
case 'v': {
fwprintf(stdout, _(L"%s, version %s\n"), PACKAGE_NAME, get_fish_version());
exit(0);