Last active
June 30, 2025 18:31
-
-
Save bendrucker/cea3628c7e3e26b740ee708116b989c2 to your computer and use it in GitHub Desktop.
Detect interactivity in a shell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| [ -t 0 ] && stdin_tty="yes" || stdin_tty="no" | |
| [ -t 1 ] && stdout_tty="yes" || stdout_tty="no" | |
| [ -t 2 ] && stderr_tty="yes" || stderr_tty="no" | |
| echo "- stdin TTY: $stdin_tty" | |
| echo "- stdout TTY: $stdout_tty" | |
| echo "- stderr TTY: $stderr_tty" | |
| echo "- TERM: ${TERM}" | |
| echo "- COLORTERM: ${COLORTERM}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment