How to set default display mode in psql

Ryne Everett picture Ryne Everett · Jan 4, 2014 · Viewed 9.7k times · Source

Almost every psql query comes out an illegible mess if not preceded by display configuration commands such as \x auto. Typing this manually for each psql instance is annoying.

Expanded display is used automatically.

Is there any way to configure a better default display? Or perhaps the answer is to use a more advanced interactive terminal?

Answer

Craig Ringer picture Craig Ringer · Jan 5, 2014

Use .psqlrc to set defaults.

For the specific case of \x, newer psql versions (9.3, I think, but it might just be the 9.4 pre-release) can automatically switch to expanded output mode when the rows are too wide to fit on a line. From \?:

\x [on|off|auto] toggle expanded output (currently off)

So I suggest putting \x auto in your .psqlrc, rather than forcing it to on.