m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-16 07:13:48 -05:00

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
This commit is contained in:
Junegunn Choi
2024-05-23 20:08:20 +09:00
parent d4216b0dcc
commit 3dee8778d0
9 changed files with 80 additions and 66 deletions

View File

@@ -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
}