Skip to main content

fish_functions/forget_last_command.fish

1# Removes the last-typed command from my fish history.
2#
3# This means that if I mistype a command and it starts appearing in
4# my suggested commands, I can type it one more time then purge it from
5# my history, to prevent it being suggested again.
6#
7# See https://alexwlchan.net/2023/forgetful-fish/
8# See https://github.com/fish-shell/fish-shell/issues/10066
9function forget_last_command --description "Remove the last-typed command from my fish history"
10 set last_typed_command (history --max 1)
11 history delete --exact --case-sensitive "$last_typed_command"
12 history save
13end