Clearing the fish shell history

Googling, searching here, the help HTML manual, etc. hasn’t produced a solution which has led me here to post…

At work and at home I use SLES 12 SP5 LTSS, 15 SP5 and SP6, RHEL 8.10, 9.2, and 9.4, Ubuntu 22.04.4, 24.04, Alma 9.4, Rocky 9.4, and Pop!_OS 22.04… I’ve been running at least one Linux distro annually since Red Hat Hedwig.

I recently built a system for my friends daughter and because of the Steam Deck I wanted to see how Arch works for her. CachyOS has thus far been AWESOME but there’s just this one issue. I would like to clear the history of the fish shell but for the life of me am unable to find the command(s) to do so.

Can someone please provide the command(s) that I am missing? fish(1) — Arch manual pages doesn’t answer this and links to a page that cannot be found (https://man.archlinux.org/man/fish-doc.1.en).

There are multiple ways to go about this. It all depends on what you would be ok with her being able to do and what you are not ok with being her being able to do. Since you claim to want to clear the history that provides some leeway into how to proceed here.

I mean if I come in and do a flurry of things or have her father or mother do them for me on the phone we’d like to be able to do the equivalent of “history -c” and “history -w” but thus far how such is done in the fish shell has eluded me. Nothing at history - show and manipulate command history — fish-shell 3.7.0 documentation has resulted in anything being cleared…

Aren’t fish history saved in a file in ~/.local/share/fish/fish_history? If so maybe it is enough to delete lines from that file or just delete it altogether?

1 Like

That is the ideal route I was leaning towards here.

So here is what you can do. You can either type history clear or the longer alternative Use nano ~/./local/share/fish/fish_history, delete all the lines that you don’t want saved there, than hit ctrl+o, press enter, then press y, then press enter again, then press ctrl+x, this should be the steps to erase the history.

Reason for my coming here was that “history clear” cleared nothing. For ease:

rm ~/./.local/share/fish/fish_history

Works! Thank you ruptotus!

Have to wonder why history clear didn’t work.