From: | gparc(at)free(dot)fr |
---|---|
To: | Dominique Devienne <ddevienne(at)gmail(dot)com> |
Cc: | Asad Ali <asadalinagri(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Customize psql prompt to show current_role |
Date: | 2024-09-23 12:49:15 |
Message-ID: | 2094959968.511571297.1727095755371.JavaMail.zimbra@free.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
----- Mail original -----
> De: "Dominique Devienne" <ddevienne(at)gmail(dot)com>
> À: "Asad Ali" <asadalinagri(at)gmail(dot)com>
> Cc: pgsql-general(at)postgresql(dot)org
> 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 <asadalinagri(at)gmail(dot)com> 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(at)%/ (%`current_role`)=%# '
> 'current_role' is not recognized as an internal or external command,
> operable program or batch file.
> ddevienne(at)ddevienne ()=> select 1;
> ...
> 'current_role' is not recognized as an internal or external command,
> operable program or batch file.
> ddevienne(at)ddevienne ()=>
> ```
Hello Dominique,
I will use psql \gset command for this
Regards
Gilles
From | Date | Subject | |
---|---|---|---|
Next Message | Erik Wienhold | 2024-09-23 12:51:08 | Re: Customize psql prompt to show current_role |
Previous Message | Dominique Devienne | 2024-09-23 12:34:39 | Re: Customize psql prompt to show current_role |