Reputation: 23014
I have a shell script that runs in my personal terminal and in a CI environment. In the CI environment, the python calls for determining shell height/width return funny values.
I would like to do something to the effect of:
if (I am running in shell context)
determine height/width of terminal
else
don't
fi
How can I express this condition, in a bash script?
Upvotes: 4
Views: 830
Reputation: 16122
Check if standard input is a tty device.
In sh/bash:
if [ -t 0 ]; then
In Python:
if os.isatty(sys.stdin):
Upvotes: 6