From 5abc3e220407cdaac88e5cb33ff2a7b73a80d54f Mon Sep 17 00:00:00 2001 From: Javi Merino Date: Mon, 9 May 2022 07:03:59 +0100 Subject: [PATCH] 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. --- zsh-fzf-history-search.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zsh-fzf-history-search.zsh b/zsh-fzf-history-search.zsh index 50876ff..5e4dbe7 100644 --- a/zsh-fzf-history-search.zsh +++ b/zsh-fzf-history-search.zsh @@ -19,7 +19,7 @@ typeset -g ZSH_FZF_HISTORY_SEARCH_END_OF_LINE='' fzf_history_search() { setopt extendedglob - candidates=(${(f)"$(fc -li -1 0 | fzf $(echo $ZSH_FZF_HISTORY_SEARCH_FZF_ARGS) $(echo $ZSH_FZF_HISTORY_SEARCH_FZF_EXTRA_ARGS) -q "$BUFFER")"}) + candidates=(${(f)"$(fc -li -1 0 | fzf ${=ZSH_FZF_HISTORY_SEARCH_FZF_ARGS} ${=ZSH_FZF_HISTORY_SEARCH_FZF_EXTRA_ARGS} -q "$BUFFER")"}) local ret=$? if [ -n "$candidates" ]; then BUFFER="${candidates[@]/(#m)*/${${(As: :)MATCH}[4,-1]}}"