Your piece of code works fine. But this one doesn't:
term("source $VIFM/scripts/fzf_vifm_integration.bash && echo $(__fzf_cd__ 2>/dev/tty | sed 's/\s*builtin cd --\s*//')")
When interrupting (by escape, for instance) long running fzf loading process one gets the error: sed: couldn't write 64 items to stdout: Broken pipe
$VIFM/scripts/fzf_vifm_integration.bash (copied from fzf's key-bindings.bash):
__fzfcmd() {
[[ -n "${TMUX_PANE-}" ]] && { [[ "${FZF_TMUX:-0}" != 0 ]] || [[ -n "${FZF_TMUX_OPTS-}" ]]; } &&
echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf"
}
__fzf_cd__() {
local cmd opts dir
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 | command cut -b3-"}"
opts="--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore --reverse --scheme=path ${FZF_DEFAULT_OPTS-} ${FZF_ALT_C_OPTS-} +m"
dir=$(set +o pipefail; eval "$cmd" | FZF_DEFAULT_OPTS="$opts" $(__fzfcmd)) && printf 'builtin cd -- %q' "$dir"
}
There is set +o pipefail, but for some reason calling __fzf_cd__ directly from the shell and interrupting it by escape doesn't produce any errors.
I'm trying to reuse my FZF_ALT_C_COMMAND and FZF_ALT_C_OPTS defined in .bashrc and call fzf intrinsics (__fzf_cd__) to make fzf use my already defined fzf options for searching directories and get identical experience in vifm and bash.