HISTORY(1)
π HISTORY(1) β fish-shell, bestie edition π
okay so this is history(1) from the fish-shell fam β the page that teaches you how to search, delete, and generally wrangle your interactive command history. no cap, it's lowkey one of the most useful things ever. let's get into it π«Ά
β¨ NAME β¨
history β show and manipulate command history. that's it. that's the vibe. π
πΈ SYNOPSIS πΈ
history [search] [--show-time] [--case-sensitive]
[--exact | --prefix | --contains] [--max N] [--null] [--reverse]
[SEARCH_STRING ...]
history delete [--case-sensitive]
[--exact | --prefix | --contains] SEARCH_STRING ...
history merge
history save
history clear
history clear-session
history append COMMAND ...
look at all those little modes. main character energy honestly π
π DESCRIPTION π
history is the tool for searching, deleting, and otherwise manipulating the history of interactive commands. (that's the section linked as <#history-search> in the original docs, iykyk.)
here are all the operations β the sub-commands β that you can run:
searchβ returns history items that match your search string. no search string? then it just gives you everything, bestie. this is the default operation if you don't name a different one. you only have to typehistory searchexplicitly if you're trying to search for a word that happens to be one of the subcommands (messy, i know). if you don't pick a different search option, the--containssearch option gets used. entries come ordered newest to oldest unless you pass--reverse. oh and β if stdout is attached to a tty, the output gets piped through your pager by thehistoryfunction. thehistorybuiltin writes the results to stdout.deleteβ deletes history items π. if you don't specify a different search option, the--containssearch option is used. if you don't pass--exact, a prompt pops up before anything gets deleted, asking you which entries you want gone. you can type the word"all"to delete every matching entry. you can type a single ID (the number in square brackets) to delete just that one entry. you can enter more than one ID, or an ID range separated by a space, to delete multiple entries at once. press enter and nothing gets deleted. heads up: that interactive delete behavior is a feature of thehistoryfunction. thehistorybuiltin only supports--exact --case-sensitivedeletion.mergeβ immediately incorporates history changes from other sessions. normally fish just ignores history changes from sessions that started after the current one. this command applies those changes right away π₯.saveβ immediately writes all changes to the history file. the shell saves the history file automatically anyway; this option exists for internal use and normally you shouldn't need it. consider it a backstage pass ποΈ.clearβ clears the history file. a prompt shows up before the history gets erased, asking you to confirm you really want to nuke all history β unless thehistorybuiltin is used.clear-sessionβ clears the history file of all activity from the current session. note: ifhistory mergeor the builtinhistory mergewas run in a session, only the history after that point gets erased.appendβ appends commands to the history without needing to execute them. sneaky. love it π.
and here are the options, bestie:
these flags can appear before or immediately after one of the sub-commands listed above.
-C,--case-sensitiveβ does a case-sensitive search. the default is case-insensitive.-c,--containsβ searches items in the history that contain the specified text string. this is the default for the--searchflag. not currently supported by thedeletesubcommand.-e,--exactβ searches or deletes items in the history that exactly match the specified text string. this is the default for thedeletesubcommand. note that the match is case-insensitive by default. if you really want an exact match, letter case and all, you must use the-Cor--case-sensitiveflag.-p,--prefixβ searches items in the history that begin with the specified text string. not currently supported by thedeletesubcommand.-t,--show-timeβ prepends each history entry with the date and time it 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-tdoes not accept a strftime format string β it only uses the default format. any strftime format is allowed, including%sto get the raw UNIX seconds since the epoch. β°-z,--nullβ causes history entries written by the search operations to be terminated by a NUL character rather than a newline. this lets the output be processed byread -zso multiline history entries are handled correctly. π§-*NUMBER*,-n NUMBER,--max NUMBERβ limits the matched history items to the first NUMBER matching entries. only valid forhistory search.-R,--reverseβ causes the history search results to be ordered oldest to newest, which is the order most shells use. the default is newest to oldest.--color WHENβ controls when to use syntax highlighting colors for the history entries.WHENcan beauto(the default β colorize if the output is a terminal),always, ornever. π-h,--helpβ displays help for this command.
β EXAMPLE β
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.
immaculate. no notes. π
π¦ CUSTOMIZING THE NAME OF THE HISTORY FILE π¦
by default, interactive commands get 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 won't be stored at all β very similar to private session features in web browsers π΅οΈββοΈ.
you can change fish_history at any time (by using set -x fish_history "session_name") and it takes effect right away. if you set it to "default", it uses the default session name (which is "fish").
other shells like bash and zsh use a variable named HISTFILE for a similar purpose. fish uses a different name to avoid conflicts and to signal that the behavior is different β it's a session name instead of a file path, slay. 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 avoiding leaking private or sensitive history when you're giving a presentation π.
π NOTES π
if you specify both --prefix and --contains, the last flag seen is the one that's 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. so maybe don't get attached π.
π· Copyright π·
fish-shell developers
and that's the whole page, bestie β fr fr, go forth and search your history with confidence β¨
fish-shell Β· version 4.9 Β· dated Sep 08, 2026 β mwah, thanks for reading, ily, bye πππ«Ά
π¦ where this page comes from
- arch rolling: fish 4.9.3-1 Β· GPL-2.0-only AND BSD-3-Clause AND ISC AND MIT AND PSF-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms