History deleting helper for Fish shell
I wrote back in February about a neat history command built-in to the Fish
shell that allows you to, amongst other things, delete entries from your
history.
To recap, you use it like this:
1
2
3
4
5
6
7
8
9
10
11
12
$ history delete --contains "mix echo"
[1] history search --contains "mix echo"
[2] mix echo.migrate
[3] mix echo.create
[4] mix echo.reset
[5] mix echo.setup
Enter nothing to cancel the delete, or
Enter one or more of the entry IDs separated by a space, or
Enter "all" to delete all the matching entries.
[I] Delete which entries? >
This is really cool, but the only thing missing for me was the ability to
fuzzily find history entries, so I wrote a quick Fish function to combine
history with fzf, my favourite shell program. I also made a small
change to the history command by swapping --contains for --prefix which
makes more sense when combined with fzf as the search is more constrained.
1
2
3
function dh -d "Fuzzily delete entries from your history"
history | fzf | read -l item; and history delete --prefix "$item"
end
Now you can type dh and fuzzily search for history before being dropped into
the interactive prompt as usual.