There's no configuration to do this automatically with the history function itself, no. From the Fish docs:
Any duplicate history items are automatically removed.
However, if the goal is simply to capture the what you entered so that you can review the commands later (in the proper context), that's it's entirely possible via scripting. At a simple level, what you want to do is simply save every command entered at the prompt into a file that doesn't remove duplicates.
Create the following function in ~/.config/fish/conf.d/save_full_history.fish
:
function log_command --on-event fish_preexec
echo $argv[1] >> ~/.local/share/fish/fish_full_history
end
That does a few things:
- By having it in
~/.config/fish/conf.d
, it will automatically load the function every time Fish starts. This is done through conf.d
since --on-event
(and other) hooks aren't activated in lazy-loaded Fish functions.
- Using the
--on-event fish_preexec
, the function runs just after Enter is pressed for each command.
- The function receives the full commandline that was entered as
$argv[1]
, saving it to the ~/.local/share/fish/fish_full_history
file for future review.
You could, of course, add something like a timestamp to this. E.g.:
echo $(date --iso-8601=ns) --- $argv[1] >> ~/.local/share/fish/fish_full_history
You could also create a separate function (it can be in the same file) that executed on fish_posterror
to make a note in the file when the command resulted in an error.