mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
parent
91ae39008a
commit
472e186c2b
8 changed files with 21 additions and 18 deletions
|
@ -34,8 +34,8 @@ This section is for changes merged to the `major` branch that are not also merge
|
||||||
- Invalid array indexes are now silently ignored (#826, #4127).
|
- Invalid array indexes are now silently ignored (#826, #4127).
|
||||||
- `string escape` has a new `--style=xxx` flag where `xxx` can be `script`, `var`, or `url` (#4150).
|
- `string escape` has a new `--style=xxx` flag where `xxx` can be `script`, `var`, or `url` (#4150).
|
||||||
- `string unescape` has been implemented to reverse the effects of `string escape` (#3543).
|
- `string unescape` has been implemented to reverse the effects of `string escape` (#3543).
|
||||||
- The history file can now be specified by setting the `FISH_HISTORY` variable (#102).
|
- The history file can now be specified by setting the `fish_history` variable (#102).
|
||||||
- Read history is now controlled by the `FISH_HISTORY` variable rather than the `--mode-name` flag (#1504).
|
- Read history is now controlled by the `fish_history` variable rather than the `--mode-name` flag (#1504).
|
||||||
- Implement a `cdh` (change directory using recent history) command to provide a more friendly alternative to prevd/nextd and pushd/popd (#2847).
|
- Implement a `cdh` (change directory using recent history) command to provide a more friendly alternative to prevd/nextd and pushd/popd (#2847).
|
||||||
- `command` now supports a `-a` flag to report all directories with the command. This means that `which -a $cmd` is no longer necessary (#2778).
|
- `command` now supports a `-a` flag to report all directories with the command. This means that `which -a $cmd` is no longer necessary (#2778).
|
||||||
- `--init-command`/`-C` added to the command line switches, to allow execution of commands before starting the interactive shell (#4164).
|
- `--init-command`/`-C` added to the command line switches, to allow execution of commands before starting the interactive shell (#4164).
|
||||||
|
|
|
@ -66,9 +66,9 @@ history delete --prefix "foo"
|
||||||
|
|
||||||
By default interactive commands are logged to `$XDG_DATA_HOME/fish/fish_history` (typically `~/.local/share/fish/fish_history`).
|
By default interactive commands are logged to `$XDG_DATA_HOME/fish/fish_history` (typically `~/.local/share/fish/fish_history`).
|
||||||
|
|
||||||
You can set the `FISH_HISTORY` variable to another name for the current shell session. The default value (when the variable is unset) is `fish` which corresponds to `$XDG_DATA_HOME/fish/fish_history`. If you set it to e.g. `fun`, the history would be written to `$XDG_DATA_HOME/fish/fun_history`. An empty string means history will not be stored at all. This is similar to the private session features in web browsers.
|
You can set the `fish_history` variable to another name for the current shell session. The default value (when the variable is unset) is `fish` which corresponds to `$XDG_DATA_HOME/fish/fish_history`. If you set it to e.g. `fun`, the history would be written to `$XDG_DATA_HOME/fish/fun_history`. An empty string means history will not be stored at all. This is similar to the private session features in web browsers.
|
||||||
|
|
||||||
You can change `FISH_HISTORY` at any time (by using `set -x FISH_HISTORY "session_name"`) and it will take effect right away. If you set it to `"default"`, it will use the default session name (which is `"fish"`).
|
You can change `fish_history` at any time (by using `set -x fish_history "session_name"`) and it will take effect right away. If you set it to `"default"`, it will use the default session name (which is `"fish"`).
|
||||||
|
|
||||||
Other shells such as bash and zsh use a variable named `HISTFILE` for a similar purpose. Fish uses a different name to avoid conflicts and signal that the behavior is different (session name instead of a file path). Also, if you set the var to anything other than `fish` or `default` it will inhibit importing the bash history. That's because the most common use case for this feature is to avoid leaking private or sensitive history when giving a presentation.
|
Other shells such as bash and zsh use a variable named `HISTFILE` for a similar purpose. Fish uses a different name to avoid conflicts and signal that the behavior is different (session name instead of a file path). Also, if you set the var to anything other than `fish` or `default` it will inhibit importing the bash history. That's because the most common use case for this feature is to avoid leaking private or sensitive history when giving a presentation.
|
||||||
|
|
||||||
|
|
|
@ -852,7 +852,7 @@ The user can change the settings of `fish` by changing the values of certain var
|
||||||
|
|
||||||
- `history`, an array containing the last commands that were entered.
|
- `history`, an array containing the last commands that were entered.
|
||||||
|
|
||||||
- `FISH_HISTORY`: Name of the history session. It defaults to `fish` (which typically means the history will be saved in `~/.local/share/fish/fish_history`). This variable can be changed by the user. It does not have to be an environment variable. You can change it at will within an interactive fish session to change where subsequent commands are logged.
|
- `fish_history`: Name of the history session. It defaults to `fish` (which typically means the history will be saved in `~/.local/share/fish/fish_history`). This variable can be changed by the user. It does not have to be an environment variable. You can change it at will within an interactive fish session to change where subsequent commands are logged.
|
||||||
|
|
||||||
- `HOME`, the user's home directory. This variable can be changed by the user.
|
- `HOME`, the user's home directory. This variable can be changed by the user.
|
||||||
|
|
||||||
|
@ -1137,7 +1137,10 @@ History searches can be aborted by pressing the escape key.
|
||||||
|
|
||||||
Prefixing the commandline with a space will prevent the entire line from being stored in the history.
|
Prefixing the commandline with a space will prevent the entire line from being stored in the history.
|
||||||
|
|
||||||
The command history is stored in the file `~/.local/share/fish/fish_history` (or `$XDG_DATA_HOME/fish/fish_history` if that variable is set) by default. However, you can set the `FISH_HISTORY` environment variable to change the name of the history session (resulting in a `<session>_history` file); both before starting the shell and while the shell is running.
|
The command history is stored in the file `~/.local/share/fish/fish_history` (or
|
||||||
|
`$XDG_DATA_HOME/fish/fish_history` if that variable is set) by default. However, you can set the
|
||||||
|
`fish_history` environment variable to change the name of the history session (resulting in a
|
||||||
|
`<session>_history` file); both before starting the shell and while the shell is running.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ is set to empty and the exit status is set to 122. This limit can be altered wit
|
||||||
|
|
||||||
\subsection read-history Using another read history file
|
\subsection read-history Using another read history file
|
||||||
|
|
||||||
The `read` command supported the `-m` and `--mode-name` flags in fish versions prior to 2.7.0 to specify an alternative read history file. Those flags are now deprecated and ignored. Instead, set the `FISH_HISTORY` variable to specify a history session ID. That will affect both the `read` history file and the fish command history file. You can set it to an empty string to specify that no history should be read or written. This is useful for presentations where you do not want possibly private or sensitive history to be exposed to the audience but do want history relevant to the presentation to be available.
|
The `read` command supported the `-m` and `--mode-name` flags in fish versions prior to 2.7.0 to specify an alternative read history file. Those flags are now deprecated and ignored. Instead, set the `fish_history` variable to specify a history session ID. That will affect both the `read` history file and the fish command history file. You can set it to an empty string to specify that no history should be read or written. This is useful for presentations where you do not want possibly private or sensitive history to be exposed to the audience but do want history relevant to the presentation to be available.
|
||||||
|
|
||||||
\subsection read-example Example
|
\subsection read-example Example
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ static int parse_cmd_opts(read_cmd_opts_t &opts, int *optind, //!OCLINT(high nc
|
||||||
}
|
}
|
||||||
case L'm': {
|
case L'm': {
|
||||||
streams.err.append_format(_(L"%ls: flags '--mode-name' / '-m' are now ignored. "
|
streams.err.append_format(_(L"%ls: flags '--mode-name' / '-m' are now ignored. "
|
||||||
L"Set FISH_HISTORY instead.\n"),
|
L"Set fish_history instead.\n"),
|
||||||
cmd);
|
cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -847,7 +847,7 @@ static void setup_var_dispatch_table() {
|
||||||
var_dispatch_table.emplace(L"LINES", handle_term_size_change);
|
var_dispatch_table.emplace(L"LINES", handle_term_size_change);
|
||||||
var_dispatch_table.emplace(L"COLUMNS", handle_term_size_change);
|
var_dispatch_table.emplace(L"COLUMNS", handle_term_size_change);
|
||||||
var_dispatch_table.emplace(L"FISH_READ_BYTE_LIMIT", handle_read_limit_change);
|
var_dispatch_table.emplace(L"FISH_READ_BYTE_LIMIT", handle_read_limit_change);
|
||||||
var_dispatch_table.emplace(L"FISH_HISTORY", handle_fish_history_change);
|
var_dispatch_table.emplace(L"fish_history", handle_fish_history_change);
|
||||||
var_dispatch_table.emplace(L"TZ", handle_tz_change);
|
var_dispatch_table.emplace(L"TZ", handle_tz_change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
//
|
//
|
||||||
// Newlines are replaced by \n. Backslashes are replaced by \\.
|
// Newlines are replaced by \n. Backslashes are replaced by \\.
|
||||||
|
|
||||||
// This is the history session ID we use by default if the user has not set env var FISH_HISTORY.
|
// This is the history session ID we use by default if the user has not set env var fish_history.
|
||||||
#define DFLT_FISH_HISTORY_SESSION_ID L"fish"
|
#define DFLT_FISH_HISTORY_SESSION_ID L"fish"
|
||||||
|
|
||||||
// When we rewrite the history, the number of items we keep.
|
// When we rewrite the history, the number of items we keep.
|
||||||
|
@ -1831,7 +1831,7 @@ void history_sanity_check() {
|
||||||
wcstring history_session_id() {
|
wcstring history_session_id() {
|
||||||
wcstring result = DFLT_FISH_HISTORY_SESSION_ID;
|
wcstring result = DFLT_FISH_HISTORY_SESSION_ID;
|
||||||
|
|
||||||
const auto var = env_get(L"FISH_HISTORY");
|
const auto var = env_get(L"fish_history");
|
||||||
if (var) {
|
if (var) {
|
||||||
wcstring session_id = var->as_string();
|
wcstring session_id = var->as_string();
|
||||||
if (session_id.empty()) {
|
if (session_id.empty()) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
# vim: set filetype=expect:
|
# vim: set filetype=expect:
|
||||||
# We're going to use three history files, including the default, to verify
|
# We're going to use three history files, including the default, to verify
|
||||||
# that the FISH_HISTORY variable works as expected.
|
# that the fish_history variable works as expected.
|
||||||
set default_histfile "../test/data/fish/fish_history"
|
set default_histfile "../test/data/fish/fish_history"
|
||||||
set my_histfile "../test/data/fish/my_history"
|
set my_histfile "../test/data/fish/my_history"
|
||||||
set env_histfile "../test/data/fish/env_history"
|
set env_histfile "../test/data/fish/env_history"
|
||||||
|
|
||||||
# =============
|
# =============
|
||||||
# Verify that if we spawn fish with no FISH_HISTORY env var it uses the
|
# Verify that if we spawn fish with no fish_history env var it uses the
|
||||||
# default file.
|
# default file.
|
||||||
# =============
|
# =============
|
||||||
set fish_pid [spawn $fish]
|
set fish_pid [spawn $fish]
|
||||||
|
@ -34,7 +34,7 @@ expect_prompt -re "\r\n$hist_line\r\n" {
|
||||||
# history file is not written to.
|
# history file is not written to.
|
||||||
set cmd2 "echo $fish_pid my histfile"
|
set cmd2 "echo $fish_pid my histfile"
|
||||||
set hist_line "- cmd: $cmd2"
|
set hist_line "- cmd: $cmd2"
|
||||||
send "set FISH_HISTORY my\r"
|
send "set fish_history my\r"
|
||||||
expect_prompt
|
expect_prompt
|
||||||
send "$cmd2\r"
|
send "$cmd2\r"
|
||||||
expect_prompt
|
expect_prompt
|
||||||
|
@ -62,7 +62,7 @@ expect_prompt -re "\r\n$hist_line\r\n" {
|
||||||
# Switch back to the default history file.
|
# Switch back to the default history file.
|
||||||
set cmd3 "echo $fish_pid default histfile again"
|
set cmd3 "echo $fish_pid default histfile again"
|
||||||
set hist_line "- cmd: $cmd3"
|
set hist_line "- cmd: $cmd3"
|
||||||
send "set FISH_HISTORY default\r"
|
send "set fish_history default\r"
|
||||||
expect_prompt
|
expect_prompt
|
||||||
send "$cmd3\r"
|
send "$cmd3\r"
|
||||||
expect_prompt
|
expect_prompt
|
||||||
|
@ -94,15 +94,15 @@ expect_prompt -re "\r\n$hist_line\r\n" {
|
||||||
send "exit\r"
|
send "exit\r"
|
||||||
close $spawn_id
|
close $spawn_id
|
||||||
|
|
||||||
# Set the FISH_HISTORY env var.
|
# Set the fish_history env var.
|
||||||
set ::env(FISH_HISTORY) env
|
set ::env(fish_history) env
|
||||||
|
|
||||||
# Spawn a new shell.
|
# Spawn a new shell.
|
||||||
set prompt_counter 1
|
set prompt_counter 1
|
||||||
set fish_pid [spawn $fish]
|
set fish_pid [spawn $fish]
|
||||||
expect_prompt
|
expect_prompt
|
||||||
|
|
||||||
# Verify that the new fish shell is using the FISH_HISTORY value for history.
|
# Verify that the new fish shell is using the fish_history value for history.
|
||||||
set cmd4 "echo $fish_pid env histfile"
|
set cmd4 "echo $fish_pid env histfile"
|
||||||
set hist_line "- cmd: $cmd4"
|
set hist_line "- cmd: $cmd4"
|
||||||
send "$cmd4\r"
|
send "$cmd4\r"
|
||||||
|
|
Loading…
Reference in a new issue