How to display Postgres version in the CLI pompt?
Since 9.3, you can do this using \gset in psqlrc:

select split_part(version(),' ',2) pmt
\gset
\set PROMPT1 '%:pmt:'


Or, as 'the value of the selected prompt variable is printed literally, except where a percent sign (%) is encountered':

select split_part(version(),' ',2) "PROMPT1"
\gset


If your version is &lt;9.3, it's still possible, but much uglier, e.g. something like:

\set PROMPT1 `psql postgres postgres -Atc "select split_part(version(),' ',2)"`