How to delete entries from fish shell's command history?
Asked Answered
R

3

29

In an attempt to unlock the screen, I have accidentally entered my password into a terminal running the fish shell.

How can I remove it from the command history of fish again?

The solution does not need to be forensically secure. Traces left in backup files or on the drive are fine with me. I just want to avoid e.g. my password accidentally popping up in a screen sharing session when I use fish's history while sharing. And I want to keep all the other commands in the history, because I often recall complicated commands from the history, sometimes editing them before reusing.

Randi answered 24/5, 2020 at 20:14 Comment(0)
P
43

You want history delete. That should ask you for a search term, show you matching entries and ask you for which to delete.

Preemie answered 24/5, 2020 at 20:29 Comment(0)
R
3

Just an addition to history delete.

--contains / -c - Shows you the results in a prompt before it gets deleted. Since it is the default, you do not need to specify the flag as shown in the examples.

  • history delete --contains "supersecretpw"
  • history delete -c "supersecretpw"
  • history delete "supersecretpw"

Another handy shortcut history clear-session will only delete the current session.

Remains answered 18/4, 2023 at 9:24 Comment(0)
T
2

I found the default folder on linux is ~/.local/share/fish/fish_history. This is very similar to .bash_history. You must be able to view and manipulate history in a non-programmatic and flexible way.

Thurlow answered 11/10, 2022 at 16:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.