diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index 407849019d6..4d2d947ee57 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -15,6 +15,7 @@ # Key bindings # ------------ function fzf_key_bindings + test -t 0; or set -gx STDIN_NOT_TTY 1 function __fzf_defaults # $1: Prepend to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS @@ -93,8 +94,13 @@ function fzf_key_bindings 'string join0 -- $i\t(string replace -a -- \n \n\t $h[$i] | string collect);' \ 'end' end - eval (__fzfcmd) --read0 --print0 -q '(commandline)' --bind='enter:become:"string replace -a -- \n\t \n {2..} | string collect"' | read -lz result - and commandline -- $result + if test "$STDIN_NOT_TTY" = 1 + eval $FZF_DEFAULT_COMMAND | eval (__fzfcmd) --read0 --print0 -q '(commandline)' --bind='enter:become:"string replace -a -- \n\t \n {2..} | string collect"' | read -lz result + and commandline -- $result + else + eval (__fzfcmd) --read0 --print0 -q '(commandline)' --bind='enter:become:"string replace -a -- \n\t \n {2..} | string collect"' | read -lz result + and commandline -- $result + end else builtin history | eval (__fzfcmd) -q '(commandline)' | read -l result and commandline -- $result