From 3dee8778d073199e0fe1e186e54f7eabc2fdef43 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 23 May 2024 20:08:20 +0900 Subject: execute: Open separate handles to /dev/tty (in, out, err) # This will no longer cause 'Vim: Warning: Output is not to a terminal' fzf --bind 'enter:execute:vim {}' > /tmp/foo --- src/proxy.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/proxy.go') diff --git a/src/proxy.go b/src/proxy.go index adeea213..5ee7317c 100644 --- a/src/proxy.go +++ b/src/proxy.go @@ -60,7 +60,7 @@ func runProxy(commandPrefix string, cmdBuilder func(temp string) *exec.Cmd, opts var command string commandPrefix += ` --proxy-script "$0"` - if opts.Input == nil && util.IsTty() { + if opts.Input == nil && util.IsTty(os.Stdin) { command = fmt.Sprintf(`%s > %q`, commandPrefix, output) } else { input, err := fifo("proxy-input") @@ -131,7 +131,11 @@ func runProxy(commandPrefix string, cmdBuilder func(temp string) *exec.Cmd, opts env = elems[1:] } executor := util.NewExecutor(opts.WithShell) - executor.Become(tui.TtyIn(), env, command) + ttyin, err := tui.TtyIn() + if err != nil { + return ExitError, err + } + executor.Become(ttyin, env, command) } return code, err } -- cgit v1.2.3