Re: Server name in psql prompt

From: Mark Morgan Lloyd <markMLl(dot)pgsql-general(at)telemetry(dot)co(dot)uk>
To: pgsql-general(at)PostgreSQL(dot)org
Subject: Re: Server name in psql prompt
Date: 2010-01-09 14:14:18
Message-ID: hia2vq$a66$1@pye-srv-01.telemetry.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)%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(at)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(at)%: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]

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Randall Thompson 2010-01-09 14:19:20 Re: pgsql2shp usage
Previous Message Daniel Verite 2010-01-09 14:12:48 Re: set-level update fails with unique constraint violation