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 type history search explicitly 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 --contains search 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 the history function. the history builtin writes the results to stdout.
  • delete β€” deletes history items πŸ’€. if you don't specify a different search option, the --contains search 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 the history function. the history builtin only supports --exact --case-sensitive deletion.
  • 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 the history builtin is used.
  • clear-session β€” clears the history file of all activity from the current session. note: if history merge or the builtin history merge was 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 --search flag. not currently supported by the delete subcommand.
  • -e, --exact β€” searches or deletes items in the history that exactly match the specified text string. this is the default for the delete subcommand. note that the match is case-insensitive by default. if you really want an exact match, letter case and all, you must use the -C or --case-sensitive flag.
  • -p, --prefix β€” searches items in the history that begin with the specified text string. not currently supported by the delete subcommand.
  • -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 -t does not accept a strftime format string β€” it only uses the default format. any strftime format is allowed, including %s to 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 by read -z so multiline history entries are handled correctly. 🧚
  • -*NUMBER*, -n NUMBER, --max NUMBER β€” limits the matched history items to the first NUMBER matching entries. only valid for history 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. WHEN can be auto (the default β€” colorize if the output is a terminal), always, or never. 🌈
  • -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 πŸ™ˆ.


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