Using fzf 0.16.8 with ripgrep 0.5.2 and zsh 5.3.1 (all installed with homebrew), on iTem2 3.0.15 and MacOS 10.11.6. Extract from my .zshrc file:
if [[ -f ~/.fzf.zsh ]]; then
export FZF_DEFAULT_OPTS='-e --color fg:-1,bg:-1,hl:3,fg+:7,bg+:0,hl+:3 --color info:3,prompt:4,pointer:1,marker:5,spinner:3,header:-1'
if (( ${+commands[rg]} )); then
export FZF_DEFAULT_COMMAND='rg -u --files'
_fzf_compgen_path() {
rg -u --files "$1"
}
fi
(( ${+FZF_DEFAULT_COMMAND} )) && export FZF_CTRL_T_COMMAND=${FZF_DEFAULT_COMMAND}
source ~/.fzf.zsh
fi
Issue is not reproducible calling fzf on the command line or using the Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim' vim plugin.
Seems to be related to bracketed paste mode.
Right, unset zle_bracketed_paste fixes the issue. But we can instead update fzf widgets to manually toggle bracketed paste mode like so.
diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh
index caa6c38..88333fc 100644
--- a/shell/key-bindings.zsh
+++ b/shell/key-bindings.zsh
@@ -27,8 +27,11 @@ __fzfcmd() {
}
fzf-file-widget() {
+ setopt localoptions noksh_arrays 2> /dev/null
+ print -nr ${zle_bracketed_paste[2]} >/dev/tty
LBUFFER="${LBUFFER}$(__fsel)"
local ret=$?
+ print -nr ${zle_bracketed_paste[1]} >/dev/tty
zle redisplay
typeset -f zle-line-init >/dev/null && zle zle-line-init
return $ret
@@ -40,8 +43,10 @@ bindkey '^T' fzf-file-widget
fzf-cd-widget() {
local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-o -type d -print 2> /dev/null | cut -b3-"}"
- setopt localoptions pipefail 2> /dev/null
+ setopt localoptions pipefail noksh_arrays 2> /dev/null
+ print -nr ${zle_bracketed_paste[2]} >/dev/tty
local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"
+ print -nr ${zle_bracketed_paste[1]} >/dev/tty
if [[ -z "$dir" ]]; then
zle redisplay
return 0
@@ -58,10 +63,12 @@ bindkey '\ec' fzf-cd-widget
# CTRL-R - Paste the selected command from history into the command line
fzf-history-widget() {
local selected num
- setopt localoptions noglobsubst noposixbuiltins pipefail 2> /dev/null
+ setopt localoptions noglobsubst noposixbuiltins pipefail noksh_arrays 2> /dev/null
+ print -nr ${zle_bracketed_paste[2]} >/dev/tty
selected=( $(fc -l 1 |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS --tac -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(q)LBUFFER} +m" $(__fzfcmd)) )
local ret=$?
+ print -nr ${zle_bracketed_paste[1]} >/dev/tty
if [ -n "$selected" ]; then
num=$selected[1]
if [ -n "$num" ]; then
We also have to do this on completion.zsh. Seems like a lot of work. I wonder if there's a simpler way.
Issue was not present on version 0.15.9 and was present on version 0.16.1 (didn't check 0.16.0)
This actually turned out to be a bug introduced in 0.16.0 when I implemented the new renderer without ncurses. Can you build fzf from the source and try again? Install Go (brew install go) and just type in make install in ~/.fzf.
Or brew reinstall fzf --HEAD if you installed fzf binary with brew.
It works with HEAD code. Thank you!