I am trying to convert some bash dotfiles to their fish equivalents.
I have a ~/.bash_logout
that looks like this:
# Flush the in-memory history, then persist the emptiness to disk.
history -c && history -w;
While fish does have a history
command, it does not have the same options, so the above will not work as-is in fish.
The closest I have gotten so far is history clear
, though this only seems to apply to the current session and is not persisted, as the history comes back in any new tabs I create. Further, it prompts for confirmation and I would prefer not to have to do that every time I log out.
Nonetheless, it is progress, so based on another answer, I put this in ~/.config/fish/config.fish
:
function on_exit --on-process %self
history clear
end
This doesn't seem to even prompt me, let alone do anything useful. Or if it does, it's non-blocking and happens so fast that I can't see it.
How can I permanently erase the fish shell history and persist that state for future sessions, within an exit handler? Existing sessions would be nice too, but are less important.
Lastly, the history
manpages notes that the "builtin history" does not prompt for confirmation. Does it make sense to use that instead and if so, how?
· clear 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 builtin history is used.