Skip to content

Commit

Permalink
Make fuzzy history searching sliiightly better
Browse files Browse the repository at this point in the history
* Don't limit to the most recent 2000 entries. fzf can handle 20k history
  entries just fine.
* Use an anchored regexp in sed to show what's being removed (the history
  timestamp)
* Reformat onto two lines
  • Loading branch information
gabebw committed Jul 4, 2016
1 parent f673aa0 commit 5e4beca
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions zsh/key_bindings.zsh
Expand Up @@ -2,11 +2,10 @@
bindkey -v

# Fuzzy match against history, edit selected value
# For exact match, start the query with a single quote: 'curl
fuzzy-history() {
print -z $(fc -l 1 | \
tail -2000 | \
fzf --tac --reverse --no-sort | \
sed 's/ *[0-9]* *//')
selected=$(fc -l 1 | sed 's/^[0-9]* *//' | fzf --tac --reverse --no-sort)
print -z "$selected"
}

# Ctrl-r triggers fuzzy history search
Expand Down

0 comments on commit 5e4beca

Please sign in to comment.