How can I tell (in ~/.bashrc) if I'm running in interactive mode, or, say, executing a command over ssh. I want to avoid printing of ANSI escape sequences in .bashrc if it's the latter.
|
feedback
|
|
According to
So you can use:
Also:
So It's best if there's no output to stdout from login In any case, it's still a good idea to test for interactivity since incorrect configuration may exist. | |||
|
feedback
|
|
I typically look at the output of the program tty. If you're on a tty, it will tell you which tty you're on. If you're not in interactive mode, it will typically tell you something like "not a tty". | |||||||
feedback
|