Created
June 9, 2023 12:43
-
-
Save Dimfred/3dba6288b1835b6a80393b0f1cadded9 to your computer and use it in GitHub Desktop.
zsh fzf reverse search (like bash)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reverse_search() { | |
sel="$( \ | |
cat ${HOME}/.zsh_history \ | |
| grep -i "$BUFFER" \ | |
| cut -d';' -f2 \ | |
| sort \ | |
| uniq -ui \ | |
| fzf)" | |
[ -z "$sel" ] && return | |
BUFFER="$sel" | |
} | |
zle -N reverse_search | |
bindkey '^R' reverse_search |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment