add a flag to limit history search results

This adds a flag to the `history search` command to limit the number of
matching entries to the first "n". The default is unlimited. This is
mostly useful in conjunction with aliases (i.e., functions) that are
intended to report the "n" most recent matching history entries without
piping the result through the user's pager.

Fixes #3244
This commit is contained in:
Kurtis Rader
2016-09-20 22:32:38 -07:00
parent c2a8de4873
commit e9b5505169
6 changed files with 58 additions and 12 deletions

View File

@@ -2,7 +2,7 @@
\subsection history-synopsis Synopsis
\fish{synopsis}
history search [ --show-time ] [ --exact | --prefix | --contains ] [ "search string"... ]
history search [ --show-time ] [ --exact | --prefix | --contains ] [ --max=n ] [ "search string"... ]
history delete [ --show-time ] [ --exact | --prefix | --contains ] "search string"...
history merge
history save
@@ -30,7 +30,7 @@ The following operations (sub-commands) are available:
The following options are available:
These flags can appear before or immediately after on of the sub-commands listed above.
These flags can appear before or immediately after one of the sub-commands listed above.
- `-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.
@@ -40,6 +40,8 @@ These flags can appear before or immediately after on of the sub-commands listed
- `-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.
- `-<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