
PostgreSQL 14 Administration Cookbook
By :

When you're connecting to multiple systems, it can be useful to configure your psql prompt so that it tells you what you are connected to.
To do this, we will edit the psql profile file so that we can execute commands when we first start psql. In the profile file, we will set values for two special variables, called PROMPT1
and PROMPT2
, that control the command-line prompt.
Identify and edit the ~/.psqlrc
file that will be executed when you start psql.
My psql prompt looks like this:
Figure 7.1 – The psql prompt set by ~./psqlrc
As you can see, it has a banner that highlights my employer's company name – I have this set for when we do demos. You can skip that part, or you can create some word art, being careful with backslashes since they are escape characters:
\echo '________ _____ _______' \echo '| ______)...
Change the font size
Change margin width
Change background colour