Setting the psql prompt with useful information
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.
Getting ready
Identify and edit the ~/.psqlrc
file that will be executed when you start psql.
How to do it…
My psql prompt looks like this:
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 '| ______)...