Go to file
Javi Merino 5abc3e2204 Avoid calling echo to expand fzf args
ZSH_FZF_HISTORY_SEARCH_FZF_ARGS and
ZSH_FZF_HISTORY_SEARCH_FZF_EXTRA_ARGS may contain multiple arguments
separated by spaces that need to be expanded to build the command line
for fzf.  This is currently done by calling a subshell and letting
echo handle it.

Unlike other shells, zsh does not do word splitting by default.
According to zshexpn(1) you can perform word splitting using the rules
for SH_WORD_SPLIT by using the ${=spec} construct.  Avoid creating a
subshell and just expand the spaces.
2022-05-09 07:18:44 +01:00
2020-08-21 23:01:21 -04:00

zsh/fzf History Search

zsh-fzf-history-search plugin screenshot

A simple zsh plugin to replace Ctrl-r with an fzf-driven, searchable list of history.

Pull requests always appreciated!

Requirements

Installation

zinit

Add this to ~/.zshrc:

# zsh-fzf-history-search
zinit ice lucid wait'0'
zinit light joshskidmore/zsh-fzf-history-search

oh-my-zsh

Clone the repository inside your oh-my-zsh repo:

git clone https://github.com/joshskidmore/zsh-fzf-history-search ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-fzf-history-search

Enable it in your .zshrc by adding it to your plugin list:

plugins=(… zsh-fzf-history-search)

Configuration Variables

Variable Description
ZSH_FZF_HISTORY_SEARCH_BIND Keybind to trigger fzf reverse search (default: '^r')
ZSH_FZF_HISTORY_SEARCH_FZF_ARGS Arguments for fzf (might be updated, not recommended to override) (default: '+s +m -x -e')
ZSH_FZF_HISTORY_SEARCH_FZF_EXTRA_ARGS Extra arguments for fzf (default: '')
ZSH_FZF_HISTORY_SEARCH_END_OF_LINE Put the cursor on at the end of the line after completion, empty=false (default: '')

TODO

  • use fzf's keybindings for additional functionality (remove specific history item, clear history, etc) while keeping plugin's simplicity in mind (issue)
  • better documentation (issue)
Languages
Shell 100%