How to I properly set the advanced FZF_DEFAULT_COMMAND environment variable to get it working properly with ohmyz.sh with fzf plugin installed?
1
vote
1
answer
1364
views
I'm new to z shell and ohmyz.sh.
I have the following in my zshrc to integrate fzf with rg. This is exactly how it appears in the fzf readme:
FZF_BASE=/usr/local/bin
DISABLE_FZF_AUTO_COMPLETION="true"
DISABLE_FZF_KEY_BINDINGS="true"
INITIAL_QUERY=""
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \
fzf --bind "change:reload:$RG_PREFIX {q} || true" \
--ansi --disabled --query "$INITIAL_QUERY" \
--height=50% --layout=reverse
It kind of works but I'm seeing some weird and broken behavior:
1. The weird behavior is that when I reload zshell, fzf fires up immediately without me hitting a key or typing in the command. It works perfectly, otherwise, though.
2. The broken behavior is that when I manually type in fzf
, the search is initiated but FZF_DEFAULT_COMMAND is set to what the plugin uses.
I tried fixing this behavior by slapping export
in front of FZF_DEFAULT_COMMAND
but then when I reload zsh, I get an error:
/Users/me/.zshrc:export:313: not valid in this context: --bind
Next I turned the ohmyzsh plugin off and modified my code to this:
FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \
fzf --bind "change:reload:$RG_PREFIX {q} || true" \
--ansi --disabled --query "$INITIAL_QUERY" \
--height=50% --layout=reverse
export FZF_DEFAULT_COMMAND
This kind of works, but again, it fires up fzf as soon as I load zsh. And the formatting of the search is mangled and ugly with ansi characters.
Asked by StevieD
(1123 rep)
Aug 29, 2021, 06:21 PM
Last activity: Aug 30, 2021, 03:42 PM
Last activity: Aug 30, 2021, 03:42 PM