is-terminal for platform
Check if the process stdin, stdout, or stderr is attached to a terminal device.
Signature
> is-terminal {flags}
Flags
--stdin, -i: Check if stdin is a terminal.--stdout, -o: Check if stdout is a terminal.--stderr, -e: Check if stderr is a terminal.
Input/output types:
| input | output |
|---|---|
| nothing | bool |
Examples
Check if stdout is a terminal (default when no flag is specified).
> is-terminalReturn "terminal attached" if standard input is attached to a terminal, and "no terminal" if not.
> if (is-terminal --stdin) { "terminal attached" } else { "no terminal" }
terminal attachedChoose formatting based on process stdout being a TTY (works inside if).
> if (is-terminal --stdout) { "human" } else { "piped" }Notes
This is an operating-system level check (like bash test -t), not a Nushell pipeline check. It reports if the process file descriptor is a TTY, which is what scripts need for ./script.nu | cat vs running on a terminal.
To detect if a custom command's return value is piped or collected inside Nushell (pretty output vs structured data), use is-redirected instead.