kelleyma49 / PSFzf

A PowerShell wrapper around the fuzzy finder fzf
MIT License
752 stars 35 forks source link

Deduplicate history before going through fzf. #219

Closed omittones closed 4 months ago

omittones commented 1 year ago

History will usually have a lot of duplicated command executions. My history for example has 18000 entries, most of which repeat. It might be faster to deduplicate history items before passing it to fzf.

Example with lots of repeated lines: image

ManuelAF commented 4 months ago

You can tell ReadLine not to store duplicates with Set-PSReadLineOption -HistoryNoDuplicates

omittones commented 4 months ago

@ManuelAF Based on documentation (link), quote:

This option controls the recall behavior. Duplicate commands are still added to the history file. When this option is set, only the most recent invocation appears when recalling commands. Repeated commands are added to history to preserve ordering during recall. However, you typically don't want to see the command multiple times when recalling or searching the history.

By default, the HistoryNoDuplicates property of the global PSConsoleReadLineOptions object is set to True

My setting IS set to True, but duplicates are still stored in the history file. My understanding is that this option only controls recall behavior via the terminal so entries won't be deduplicated even when using Get-History command, as seen in:

image

So in my case when searching "dir", without deduplication there would be many useless "dir" entries.