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.
So you can use:
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.
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".
So you can use for example: