public inbox for [email protected]  
help / color / mirror / Atom feed
From: Dominique Devienne <[email protected]>
To: Laurenz Albe <[email protected]>
Cc: Erik Wienhold <[email protected]>
Cc: Asad Ali <[email protected]>
Cc: [email protected]
Subject: Re: Customize psql prompt to show current_role
Date: Mon, 23 Sep 2024 15:08:47 +0200
Message-ID: <CAFCRh-_BR4QKqTy4AnoTgGE+AiYjAsE1BJ9KPmxU-5vNQ0h+8Q@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAFCRh-_VwScttZi4R8grSd-b=7qguAnSzXp_+jbdpUkp=TfxPQ@mail.gmail.com>
	<CAJ9xe=ttSfESR=z2YZycow8DubyfQeOgOzMDUCE95f2vN-TzFg@mail.gmail.com>
	<[email protected]>
	<CAFCRh--uBYcJ0gyBakSAzby0CmM2gvjo4Wa9OF79Od+-PXQP0A@mail.gmail.com>
	<[email protected]>

On Mon, Sep 23, 2024 at 3:05 PM Laurenz Albe <[email protected]> wrote:
> On Mon, 2024-09-23 at 14:59 +0200, Dominique Devienne wrote:
> > On Mon, Sep 23, 2024 at 2:51 PM Erik Wienhold <[email protected]> wrote:
> > > You could instead use this:
> > >
> > >     SELECT current_role \gset
> > >     \set PROMPT1 '%n@%/ (%:current_role:)=%# '
> > >
> > > But that won't work with subsequent SET ROLE commands.
> >
> > Bummer... That was kinda the point, that it updates automatically.
> >
> > Then I'd like to respectfully request a small enhancement to psql
> > to support a new \r (or some other letter) for current_role in the prompt.
>
> To get the current role, psql would have to query the database whenever
> it displays the prompt.  That would be rather expensive...

Hi Laurenz. Sure, although expensive might be a bit strong a word.
But that would be opt-in anyway, so just a small warning in the doc
about that new option would suffice, no? --DD






view thread (8+ messages)  latest in thread

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Customize psql prompt to show current_role
  In-Reply-To: <CAFCRh-_BR4QKqTy4AnoTgGE+AiYjAsE1BJ9KPmxU-5vNQ0h+8Q@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox