diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2024-05-23 20:08:20 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-05-23 21:11:12 +0900 |
| commit | 3dee8778d073199e0fe1e186e54f7eabc2fdef43 (patch) | |
| tree | 1c39e76cf456b176cee9c4763ddbd8447e4ce406 /src/util | |
| parent | d4216b0dcc13567479d81cc5ad2adedb1443ea8b (diff) | |
| download | fzf-3dee8778d073199e0fe1e186e54f7eabc2fdef43.tar.gz | |
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
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/util.go | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/util/util.go b/src/util/util.go index 9b926b8d..ec5a1ea0 100644 --- a/src/util/util.go +++ b/src/util/util.go @@ -138,17 +138,12 @@ func DurWithin( return val } -// IsTty returns true if stdin is a terminal -func IsTty() bool { - fd := os.Stdin.Fd() +// IsTty returns true if the file is a terminal +func IsTty(file *os.File) bool { + fd := file.Fd() return isatty.IsTerminal(fd) || isatty.IsCygwinTerminal(fd) } -// ToTty returns true if stdout is a terminal -func ToTty() bool { - return isatty.IsTerminal(os.Stdout.Fd()) -} - // Once returns a function that returns the specified boolean value only once func Once(nextResponse bool) func() bool { state := nextResponse |
