.\" Man page generated from reStructuredText.
.
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "HISTORY" "1" "Jul 09, 2021" "3.3" "fish-shell"
.SH NAME
history \- show and manipulate command history
.SH SYNOPSIS
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
history [ search ] [ \-\-show\-time ] [ \-\-case\-sensitive ] [ \-\-exact | \-\-prefix | \-\-contains ] [ \-\-max=n ] [ \-\-null ] [ \-R | \-\-reverse ] [ "search string"... ]
history delete [ \-\-show\-time ] [ \-\-case\-sensitive ] [ \-\-exact | \-\-prefix | \-\-contains ] "search string"...
history merge
history save
history clear
history ( \-h | \-\-help )
.ft P
.fi
.UNINDENT
.UNINDENT
.SH DESCRIPTION
.sp
\fBhistory\fP is used to search, delete, and otherwise manipulate the history of interactive commands\&.
.sp
The following operations (sub\-commands) are available:
.INDENT 0.0
.IP \(bu 2
\fBsearch\fP 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 \fBhistory search\fP if you wish to search for one of the subcommands. The \fB\-\-contains\fP search option will be used if you don\(aqt specify a different search option. Entries are ordered newest to oldest unless you use the \fB\-\-reverse\fP flag. 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.
.IP \(bu 2
\fBdelete\fP deletes history items. The \fB\-\-contains\fP search option will be used if you don\(aqt specify a different search option. If you don\(aqt specify \fB\-\-exact\fP 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 \fB\-\-exact \-\-case\-sensitive\fP deletion.
.IP \(bu 2
\fBmerge\fP immediately incorporates history changes from other sessions. Ordinarily \fBfish\fP ignores history changes from sessions started after the current one. This command applies those changes immediately.
.IP \(bu 2
\fBsave\fP 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.
.IP \(bu 2
\fBclear\fP 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 \fBbuiltin history\fP is used.
.UNINDENT
.sp
The following options are available:
.sp
These flags can appear before or immediately after one of the sub\-commands listed above.
.INDENT 0.0
.IP \(bu 2
\fB\-C\fP or \fB\-\-case\-sensitive\fP does a case\-sensitive search. The default is case\-insensitive. Note that prior to fish 2.4.0 the default was case\-sensitive.
.IP \(bu 2
\fB\-c\fP or \fB\-\-contains\fP searches or deletes items in the history that contain the specified text string. This is the default for the \fB\-\-search\fP flag. This is not currently supported by the \fBdelete\fP subcommand.
.IP \(bu 2
\fB\-e\fP or \fB\-\-exact\fP searches or deletes items in the history that exactly match the specified text string. This is the default for the \fBdelete\fP subcommand. Note that the match is case\-insensitive by default. If you really want an exact match, including letter case, you must use the \fB\-C\fP or \fB\-\-case\-sensitive\fP flag.
.IP \(bu 2
\fB\-p\fP or \fB\-\-prefix\fP searches or deletes items in the history that begin with the specified text string. This is not currently supported by the \fB\-\-delete\fP flag.
.IP \(bu 2
\fB\-t\fP or \fB\-\-show\-time\fP prepends each history entry with the date and time the entry was recorded. By default it uses the strftime format \fB# %c%n\fP\&. You can specify another format; e.g., \fB\-\-show\-time="%Y\-%m\-%d %H:%M:%S "\fP or \fB\-\-show\-time="%a%I%p"\fP\&. The short option, \fB\-t\fP, doesn\(aqt accept a strftime format string; it only uses the default format. Any strftime format is allowed, including \fB%s\fP to get the raw UNIX seconds since the epoch.
.IP \(bu 2
\fB\-z\fP or \fB\-\-null\fP 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 \fBread \-z\fP to correctly handle multiline history entries.
.IP \(bu 2
\fB\-<number>\fP \fB\-n <number>\fP or \fB\-\-max=<number>\fP limits the matched history items to the first "n" matching entries. This is only valid for \fBhistory search\fP\&.
.IP \(bu 2
\fB\-R\fP or \fB\-\-reverse\fP causes the history search results to be ordered oldest to newest. Which is the order used by most shells. The default is newest to oldest.
.IP \(bu 2
\fB\-h\fP or \fB\-\-help\fP display help for this command.
.UNINDENT
.SH EXAMPLE
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
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 separated by a space.
.ft P
.fi
.UNINDENT
.UNINDENT
.SH CUSTOMIZING THE NAME OF THE HISTORY FILE
.sp
By default interactive commands are logged to \fB$XDG_DATA_HOME/fish/fish_history\fP (typically \fB~/.local/share/fish/fish_history\fP).
.sp
You can set the \fBfish_history\fP variable to another name for the current shell session. The default value (when the variable is unset) is \fBfish\fP which corresponds to \fB$XDG_DATA_HOME/fish/fish_history\fP\&. If you set it to e.g. \fBfun\fP, the history would be written to \fB$XDG_DATA_HOME/fish/fun_history\fP\&. An empty string means history will not be stored at all. This is similar to the private session features in web browsers.
.sp
You can change \fBfish_history\fP at any time (by using \fBset \-x fish_history "session_name"\fP) and it will take effect right away. If you set it to \fB"default"\fP, it will use the default session name (which is \fB"fish"\fP).
.sp
Other shells such as bash and zsh use a variable named \fBHISTFILE\fP 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 \fBfish\fP or \fBdefault\fP it will inhibit importing the bash history. That\(aqs because the most common use case for this feature is to avoid leaking private or sensitive history when giving a presentation.
.SH NOTES
.sp
If you specify both \fB\-\-prefix\fP and \fB\-\-contains\fP the last flag seen is used.
.sp
Note that for backwards compatibility each subcommand can also be specified as a long option. For example, rather than \fBhistory search\fP you can type \fBhistory \-\-search\fP\&. Those long options are deprecated and will be removed in a future release.
.SH COPYRIGHT
2021, fish-shell developers
.\" Generated by docutils manpage writer.
.
