From: Christoph Moench-Tegeder <cmt@burggraben.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to get shorter SERVER_VERSION in psql-prompt?
Date: Mon, 3 Sep 2018 23:34:48 +0200
Message-ID: <20180903213447.yruv2ua2qlik5r7h@squirrel.exwg.net> (raw)
In-Reply-To: <VisenaEmail.45.809b268f4ddd981.165a1337341@tc7-visena>
References: <VisenaEmail.45.809b268f4ddd981.165a1337341@tc7-visena>
## Andreas Joseph Krogh (andreas@visena.com):
> This results in this verver_version:
> 10.5 (Ubuntu 10.5-1.pgdg18.04+1)
>
> Is it possible to adjust this somehow so it outputs only "10.5"?
On Debian/Ubuntu, all version strings are somewhat extended.
Luckily, with the power of SQL we're not completely helpless, so try
this in your .psqlrc (somewhat simpler than your prompt, but you
get the idea):
select substring(current_setting('server_version') from '#"[^ ]+#"( +%)?' for '#') as short_server_ver\gset
\set PROMPT1 '%/ %:short_server_ver: %R%# '
Yes, that works across \c.
Happy prompting,
Christoph
--
Spare Space.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: cmt@burggraben.net
Subject: Re: How to get shorter SERVER_VERSION in psql-prompt?
In-Reply-To: <20180903213447.yruv2ua2qlik5r7h@squirrel.exwg.net>
References: <VisenaEmail.45.809b268f4ddd981.165a1337341@tc7-visena> <20180903213447.yruv2ua2qlik5r7h@squirrel.exwg.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox