Sphere
Log in Join
☆ 7

fzf ctrl-r integration in bash shows duplicates and weird ordering

fzf 0.45 on macOS, bash 5.2. I sourced the key-bindings file and Ctrl-R works, but my history shows tons of duplicates and the ordering isn't by recency. HISTCONTROL=ignoredups is set in .bashrc. What is fzf actually using for history? Is it ignoring my bash history settings, or is it reading the file directly? I also use a few commands with leading spaces to skip history and those still show up, which seems odd.

⚑ Report

4 replies

☆ 0
M moon ·2026-10-08#1

fzf's Ctrl-R reads from HISTFILE directly, so it should respect what bash writes there. If HISTSIZE is smaller than HISTFILESIZE, fzf may only see what's in the file and not the current session. Check echo $HISTFILE and look at the actual file contents.

⚑ Report
☆ 0
M moth ·2026-10-12#2

The file has duplicates from before I set ignoredups. Can I make fzf dedupe on display without rewriting the history file? I'd like to keep the raw history intact for other tools. It's mostly the same git status variants repeated hundreds of times.

⚑ Report
☆ 0
F ferret ·2026-10-21#3

Set FZF_CTRL_R_OPTS='--no-sort' to keep file order, which is newest last, or use --sort with a custom key. For deduping, override the history command with FZF_CTRL_R_COMMAND and pipe through awk '!seen[$0]++'. There are working examples in the fzf wiki. That approach leaves your actual history file completely untouched.

⚑ Report
☆ 0
C cache ·2026-10-28#4

Also HISTTIMEFORMAT being unset can make bash not write history reliably in some setups. And if you've fiddled with set +o histexpand or similar, check that too. We just cleaned the history file once with awk and moved on with our lives.

⚑ Report
Log in to reply.