mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
b53f42970c
This fixes several problems with how the builtin `history` command handles arguments. It now complains and refuses to do anything if the user specifies incompatible actions (e.g., `--search` and `--clear`). It also fixes a regression introduced by previous changes with regard to invocations that don't explicitly specify `--search` or a search term. Enhances the history man page to clarify the behavior of various options. This change is already far larger than I like so unit tests will be added in a separate commit. Fixes #3224. Note: This fixes only a couple problems with the interactive `history --delete` command in the `history` function. The main problem will be dealt with via issue #31.
54 lines
3.1 KiB
Text
54 lines
3.1 KiB
Text
\section history history - Show and manipulate command history
|
|
|
|
\subsection history-synopsis Synopsis
|
|
\fish{synopsis}
|
|
history ( -s | --search ) [ -t | --with-time ] [ -p | --prefix | -c | --contains ] [ "search string"... ]
|
|
history ( -d | --delete ) [ -t | --with-time ] [ -p | --prefix | -c | --contains ] "search string"...
|
|
history ( -m | --merge )
|
|
history ( -s | --save )
|
|
history ( -l | --clear )
|
|
history ( -h | --help )
|
|
\endfish
|
|
|
|
\subsection history-description Description
|
|
|
|
`history` is used to list, search and delete the history of commands used.
|
|
|
|
The following commands are available:
|
|
|
|
- `-s` or `--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. 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.
|
|
|
|
- `-d` or `--delete` deletes history items. Without the `--prefix` or `--contains` options, the exact match will be deleted. With either of these options, 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 bulk deletion.
|
|
|
|
- `-m` or `--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.
|
|
|
|
- `-v` or `--save` saves all changes in the history file. The shell automatically saves the history file; this option is provided for internal use.
|
|
|
|
- `-l` or `--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.
|
|
|
|
The following options are available:
|
|
|
|
- `-p` or `--prefix` searches or deletes items in the history that begin with the specified text string.
|
|
|
|
- `-c` or `--contains` searches or deletes items in the history that contain the specified text string. This is the default.
|
|
|
|
- `-t` or `--with-time` prefixes the output of each displayed history entry with the time it was recorded in the format "%Y-%m-%d %H:%M:%S" in your local timezone.
|
|
|
|
\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.
|
|
|
|
\subsection history-notes Notes
|
|
|
|
If you specify both `--prefix` and `--contains` the last flag seen is used.
|
|
|
|
\endfish
|