mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-27 03:13:37 +08:00
9e922a6e02
The `status` command currently silently allows incompatible flags (i.e., subcommands). Too, using flags to specify subcommands misleads the user into thinking they can specify multiple subcommands. We recently modified the `history` command to deprecate using flags for subcommands. This change does the same for the `status` command. Fixes #3509
68 lines
5.1 KiB
Plaintext
68 lines
5.1 KiB
Plaintext
\section history history - Show and manipulate command history
|
|
|
|
\subsection history-synopsis Synopsis
|
|
\fish{synopsis}
|
|
history search [ --show-time ] [ --case-sensitive ] [ --exact | --prefix | --contains ] [ --max=n ] [ --null ] [ "search string"... ]
|
|
history delete [ --show-time ] [ --case-sensitive ] [ --exact | --prefix | --contains ] "search string"...
|
|
history merge
|
|
history save
|
|
history clear
|
|
history ( -h | --help )
|
|
\endfish
|
|
|
|
\subsection history-description Description
|
|
|
|
`history` is used to search, delete, and otherwise manipulate the history of interactive commands.
|
|
|
|
The following operations (sub-commands) are available:
|
|
|
|
- `search` returns history items matching the search string. If no search string is provided it returns all history items. This is the default operation if no other operation is specified. You only have to explicitly say `history search` if you wish to search for one of the subcommands. The `--contains` search option will be used if you don't specify a different search option. Entries are ordered newest to oldest. If stdout is attached to a tty the output will be piped through your pager by the history function. The history builtin simply writes the results to stdout.
|
|
|
|
- `delete` deletes history items. Without the `--prefix` or `--contains` options, the exact match of the specified text will be deleted. If you don't specify `--exact` a prompt will be displayed before any items are deleted asking you which entries are to be deleted. You can enter the word "all" to delete all matching entries. You can enter a single ID (the number in square brackets) to delete just that single entry. You can enter more than one ID separated by a space to delete multiple entries. Just press [enter] to not delete anything. Note that the interactive delete behavior is a feature of the history function. The history builtin only supports `--exact --case-sensitive` deletion.
|
|
|
|
- `merge` immediately incorporates history changes from other sessions. Ordinarily `fish` ignores history changes from sessions started after the current one. This command applies those changes immediately.
|
|
|
|
- `save` immediately writes all changes to the history file. The shell automatically saves the history file; this option is provided for internal use and should not normally need to be used by the user.
|
|
|
|
- `clear` clears the history file. A prompt is displayed before the history is erased asking you to confirm you really want to clear all history unless `builtin history` is used.
|
|
|
|
The following options are available:
|
|
|
|
These flags can appear before or immediately after one of the sub-commands listed above.
|
|
|
|
- `-C` or `--case-sensitive` does a case-sensitive search. The default is case-insensitive. Note that prior to fish 2.4.0 the default was case-sensitive.
|
|
|
|
- `-c` or `--contains` searches or deletes items in the history that contain the specified text string. This is the default for the `--search` flag. This is not currently supported by the `--delete` flag.
|
|
|
|
- `-e` or `--exact` searches or deletes items in the history that exactly match the specified text string. This is the default for the `--delete` flag. Note that the match is case-insensitive by default. If you really want an exact match, including letter case, you must use the `-C` or `--case-sensitive` flag.
|
|
|
|
- `-p` or `--prefix` searches or deletes items in the history that begin with the specified text string. This is not currently supported by the `--delete` flag.
|
|
|
|
- `-t` or `--show-time` prepends each history entry with the date and time the entry was recorded . By default it uses the strftime format `# %c%n`. You can specify another format; e.g., `--show-time='%Y-%m-%d %H:%M:%S '` or `--show-time='%a%I%p'`. The short option, `-t` doesn't accept a stftime format string; it only uses the default format. Any strftime format is allowed, including `%s` to get the raw UNIX seconds since the epoch. Note that `--with-time` is also allowed but is deprecated and will be removed at a future date.
|
|
|
|
- `-z` or `--null` causes history entries written by the search operations to be terminated by a NUL character rather than a newline. This allows the output to be processed by `read -z` to correctly handle multiline history entries.
|
|
|
|
- `-<number>` `-n <number>` or `--max=<number>` limits the matched history items to the first "n" matching entries. This is only valid for `history search`.
|
|
|
|
- `-h` or `--help` display help for this command.
|
|
|
|
\subsection history-examples Example
|
|
|
|
\fish
|
|
history --clear
|
|
# Deletes all history items
|
|
|
|
history --search --contains "foo"
|
|
# Outputs a list of all previous commands containing the string "foo".
|
|
|
|
history --delete --prefix "foo"
|
|
# Interactively deletes commands which start with "foo" from the history.
|
|
# You can select more than one entry by entering their IDs seperated by a space.
|
|
\endfish
|
|
|
|
\subsection history-notes Notes
|
|
|
|
If you specify both `--prefix` and `--contains` the last flag seen is used.
|
|
|
|
Note that for backwards compatibility each subcommand can also be specified as a long option. For example, rather than `history search` you can type `history --search`. Those long options are deprecated and will be removed in a future release.
|