| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package terminal |
| 4 | |
| 5 | import ( |
| 6 | "os" |
| 7 | |
| 8 | "github.com/mattn/go-isatty" |
| 9 | ) |
| 10 | |
| 11 | // IsTerminal reports whether plugin IO is attached to a terminal. |
| 12 | // It checks stderr, stdout, and stdin. |
| 13 | func IsTerminal() bool { |
| 14 | return isatty.IsTerminal(os.Stderr.Fd()) || |
| 15 | isatty.IsTerminal(os.Stdout.Fd()) || |
| 16 | isatty.IsTerminal(os.Stdin.Fd()) |
| 17 | } |