Re: Server name in psql prompt - Mailing list pgsql-general

From Mark Morgan Lloyd
Subject Re: Server name in psql prompt
Date
Msg-id hia2vq$a66$1@pye-srv-01.telemetry.co.uk
Whole thread Raw
In response to Re: Server name in psql prompt  (Mark Morgan Lloyd <markMLl.pgsql-general@telemetry.co.uk>)
List pgsql-general
Mark Morgan Lloyd wrote:
> I thought earlier that I could use finger as a hack for querying the
> server, i.e. I could put e.g. a disc set name in /home/postgres/.plan.
> However I then realised that I'd need %M to be expanded before %`, so
> that I could do something like
>
> \set PROMPT1 '`finger postgres@%M|filter`: %/%R%# '
>
> where filter only returned the bit that was needed. I've not tried this
> due to the ordering issue.

I've just been playing with this. I can finger a fixed server for its
"true name" using e.g.

postgres: markMLl=>
\set PROMPT1 '%`finger postgres@postgres|head -1|cut -d \[ -f 2|cut -d .
-f 1`: %/%R%# '
postgres1: markMLl=>

but if I try to replace the fixed server name in that

\set PROMPT1 '%`finger postgres@%:HOST:|head...

the nested variable doesn't get expanded.

That's obviously useful if there's only one server or the servers are
pooled since it means that the current disk set or whatever can be
identified, but less so if there are multiple servers.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

pgsql-general by date:

Previous
From: "Daniel Verite"
Date:
Subject: Re: set-level update fails with unique constraint violation
Next
From: "Randall Thompson"
Date:
Subject: Re: pgsql2shp usage