public inbox for [email protected]  
help / color / mirror / Atom feed
From: [email protected]
To: Dominique Devienne <[email protected]>
Cc: Asad Ali <[email protected]>
Cc: [email protected]
Subject: Re: Customize psql prompt to show current_role
Date: Mon, 23 Sep 2024 14:49:15 +0200 (CEST)
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAFCRh-88pOKE=ybmar4x-R86JArimnhLbFryXmYVWOq6fn6Qwg@mail.gmail.com>
References: <CAFCRh-_VwScttZi4R8grSd-b=7qguAnSzXp_+jbdpUkp=TfxPQ@mail.gmail.com>
	<CAJ9xe=ttSfESR=z2YZycow8DubyfQeOgOzMDUCE95f2vN-TzFg@mail.gmail.com>
	<CAFCRh-88pOKE=ybmar4x-R86JArimnhLbFryXmYVWOq6fn6Qwg@mail.gmail.com>

----- Mail original -----
> De: "Dominique Devienne" <[email protected]>
> À: "Asad Ali" <[email protected]>
> Cc: [email protected]
> Envoyé: Lundi 23 Septembre 2024 14:34:39
> Objet: Re: Customize psql prompt to show current_role

> On Mon, Sep 23, 2024 at 2:22 PM Asad Ali <[email protected]> wrote:
>> There is no direct prompt escape sequence like %n for displaying the
>> current_role in the psql prompt.
>> However, you can work around this by using a \set command to define a custom
>> prompt that includes the result of current_role.
> 
> Hi Ali. Doesn't seem to be working for me. Did I do something wrong? --DD
> 
> ```
> D:\>psql service=pau16
> psql (17beta3, server 16.1)
> Type "help" for help.
> 
> ddevienne=> \set current_role 'SELECT current_role;'
> ddevienne=> \set PROMPT1 '%n@%/ (%`current_role`)=%# '
> 'current_role' is not recognized as an internal or external command,
> operable program or batch file.
> ddevienne@ddevienne ()=> select 1;
> ...
> 'current_role' is not recognized as an internal or external command,
> operable program or batch file.
> ddevienne@ddevienne ()=>
> ```

Hello Dominique,

I will use psql \gset command for this

Regards
Gilles






view thread (2+ messages)

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]
  Subject: Re: Customize psql prompt to show current_role
  In-Reply-To: <[email protected]>

* 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