detect if psql is started in interactive mode

Viewed 15

Question

Is there a way to detect, from within psql, if it is running in interactive mode or not ?

The check would be something like : "no -c of -f option was provided, and stdin is not a tty"

context

I would like to have a .psqlrc which outputs "connected to database xx as user yy" when running psql as an interactive shell, and outputs nothing (e.g: doesn't alter the output of the commands run by psql) when running psql in batch mode.

0 Answers
Related