is-terminal for platform
Check if stdin, stdout, or stderr is a terminal.
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 false when output is piped to another command.
> is-terminal | to text
falseReturn false when output is collected into a variable.
> let x = (is-terminal); $x
falseReturn "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 attached