ddworken / hishtory

Your shell history: synced, queryable, and in context
https://hishtory.dev
MIT License
2.46k stars 45 forks source link

Filter duplicates with map #139

Closed bnichs closed 9 months ago

bnichs commented 9 months ago

The previous method of filtering duplicates only worked on duplicates that occurred consecutively. Since dupes happen out of order often, this switches the logic to instead use a map of seen commands and filter based on that.

I don't know go super well so I couldn't figure out how to test it, but this command will reproduce the issue by printing duplicate command counts:

hishtory query "ls" | awk '{$1=$2=""; print $0}' | sort | uniq -c | sort -k1n | tail  

Running this with a local build of my branch removes all the duplicates.

ddworken commented 9 months ago

Awesome, thank you for the PR! This LGTM. 👍