public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Customize psql prompt to show current_role
2+ messages / 2 participants
[nested] [flat]

* Re: Customize psql prompt to show current_role
@ 2024-09-23 12:34  Dominique Devienne <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Dominique Devienne @ 2024-09-23 12:34 UTC (permalink / raw)
  To: Asad Ali <[email protected]>; +Cc: pgsql-general

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 ()=>
```






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Customize psql prompt to show current_role
@ 2024-09-23 12:49  [email protected]
  parent: Dominique Devienne <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: [email protected] @ 2024-09-23 12:49 UTC (permalink / raw)
  To: Dominique Devienne <[email protected]>; +Cc: Asad Ali <[email protected]>; pgsql-general

----- 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






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-09-23 12:49 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-09-23 12:34 Re: Customize psql prompt to show current_role Dominique Devienne <[email protected]>
2024-09-23 12:49 ` [email protected]

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