Обсуждение: session username in default psql prompt?
I don't recall if this has come up before.
I'm sometimes mildly annoyed when I get on a new system and find the username missing in my psql prompt. Or if a customer shows me a screen and I have to ask "which user is this". If we're dealing with several roles it can get confusing. My usual .psqlrc has
\set PROMPT1 '%n@%~%R%x%# '
So my suggestion is that we prepend '%n@' to the default psql PROMPT1 (and maybe PROMPT2).
I realize it's not exactly earth-shattering, but I think it's a bit more user-friendly.
(Would be a good beginner project, the code change would be tiny but there are lots of docs / examples that we might want to change if we did it.)
cheers
andrew
-- Andrew Dunstan EDB: https://www.enterprisedb.com
I'd like to take this if this is approved ;) On Sat, May 27, 2023 at 8:52 PM Andrew Dunstan <andrew@dunslane.net> wrote: > > I don't recall if this has come up before. > > I'm sometimes mildly annoyed when I get on a new system and find the username missing in my psql prompt. Or if a customershows me a screen and I have to ask "which user is this". If we're dealing with several roles it can get confusing.My usual .psqlrc has > > \set PROMPT1 '%n@%~%R%x%# ' > > So my suggestion is that we prepend '%n@' to the default psql PROMPT1 (and maybe PROMPT2). > > I realize it's not exactly earth-shattering, but I think it's a bit more user-friendly. > > (Would be a good beginner project, the code change would be tiny but there are lots of docs / examples that we might wantto change if we did it.) > > > cheers > > > andrew > > -- > Andrew Dunstan > EDB: https://www.enterprisedb.com -- Regards Junwang Zhao
On May 27, 2023, at 8:52 AM, Andrew Dunstan <andrew@dunslane.net> wrote:I don't recall if this has come up before.
I'm sometimes mildly annoyed when I get on a new system and find the username missing in my psql prompt. Or if a customer shows me a screen and I have to ask "which user is this". If we're dealing with several roles it can get confusing. My usual .psqlrc has
\set PROMPT1 '%n@%~%R%x%# '
So my suggestion is that we prepend '%n@' to the default psql PROMPT1 (and maybe PROMPT2).
I realize it's not exactly earth-shattering, but I think it's a bit more user-friendly.
(Would be a good beginner project, the code change would be tiny but there are lots of docs / examples that we might want to change if we did it.)
cheers
andrew
-- Andrew Dunstan EDB: https://www.enterprisedb.com
Вложения
On 2024-02-27 Tu 19:19, Kori Lane wrote: > Here’s a patch for this. > > Reposting as the archive mail processor doesn't seem to like the Apple mail attachment. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com
Вложения
On Wed, Mar 13, 2024 at 4:56 AM Andrew Dunstan <andrew@dunslane.net> wrote: > Reposting as the archive mail processor doesn't seem to like the Apple > mail attachment. I'm not really a fan of this. Right now my prompt looks like this: robert.haas=# If we did this, it would say: robert.haas@robert.haas=# I have yet to meet anyone who doesn't think that one Robert Haas is quite enough already, and perhaps too much by half. -- Robert Haas EDB: http://www.enterprisedb.com
On Wed, Mar 13, 2024 at 4:56 AM Andrew Dunstan <andrew@dunslane.net> wrote:
> Reposting as the archive mail processor doesn't seem to like the Apple
> mail attachment.
I'm not really a fan of this. Right now my prompt looks like this:
robert.haas=#
If we did this, it would say:
robert.haas@robert.haas=#
I have yet to meet anyone who doesn't think that one Robert Haas is
quite enough already, and perhaps too much by half.
Andrew Dunstan <andrew@dunslane.net> writes: > On Fri, Mar 22, 2024 at 4:04 PM Robert Haas <robertmhaas@gmail.com> wrote: >> I'm not really a fan of this. Right now my prompt looks like this: >> robert.haas=# >> If we did this, it would say: >> robert.haas@robert.haas=# There would be similar duplication for, eg, the postgres user connected to the postgres database. However, I'm more worried about the case where they don't match, because then the %~ suggestion doesn't help shorten it. > Of course, people can put this in their .psqlrc, and I do. The suggestion > came about because I had a couple of instances where people using the > default prompt showed me stuff and the problem arose from confusion about > which user they were connected as. On the whole, I think we'd get more complaints about the default prompt having more-or-less doubled in length than we'd get kudos about this being a great usability improvement. Prompt space is expensive and precious, at least for people who aren't in the habit of working in very wide windows. regards, tom lane
On the whole, I think we'd get more complaints about the default
prompt having more-or-less doubled in length than we'd get kudos
about this being a great usability improvement. Prompt space is
expensive and precious, at least for people who aren't in the
habit of working in very wide windows.
On Sat, 23 Mar 2024 at 00:34, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Prompt space is > expensive and precious, at least for people who aren't in the > habit of working in very wide windows. That problem seems easy to address by adding a newline into the default prompt. Something like this: \set PROMPT1 '%n@%~%R%\n# ' I myself use: \set PROMPT1 '%[%033[1m%]%M %n@%/:%>-%p%R%[%033[0m%]%\n> '
On Mon, 25 Mar 2024 at 09:30, Jelte Fennema-Nio <postgres@jeltef.nl> wrote: > \set PROMPT1 '%n@%~%R%\n# ' Obviously I meant to put the \n before the %: \set PROMPT1 '%n@%~%R\n%# '
On Mon, Mar 25, 2024 at 6:32 PM Jelte Fennema-Nio <postgres@jeltef.nl> wrote: > > Obviously I meant to put the \n before the %: > \set PROMPT1 '%n@%~%R\n%# ' > transaction related information lost. for example: jian@src6= # begin; BEGIN jian@src6= # select 1/0; 2024-03-25 18:37:59.313 CST [15252] ERROR: division by zero 2024-03-25 18:37:59.313 CST [15252] STATEMENT: select 1/0; ERROR: division by zero jian@src6= # rollback ; ROLLBACK master behavior: src6=# begin ; BEGIN src6=*# select 1/0; 2024-03-25 18:38:31.997 CST [24688] ERROR: division by zero 2024-03-25 18:38:31.997 CST [24688] STATEMENT: select 1/0; ERROR: division by zero src6=!# rollback ; ROLLBACK
On Mon, 25 Mar 2024 at 11:40, jian he <jian.universality@gmail.com> wrote: > transaction related information lost. Ah yeah, it seems I somehow lost the %x How about: \set PROMPT1 '%n@%~\n%R%x%# ' Or maybe even this more verbose one, which closely matches the postgresql:// connection string format: \set PROMPT1 '%n@%M:%>/%/\n%R%x%# ' or even add in some bold/colors like this, to make the prompt stand out from a query: \set PROMPT1 '%[%033[1m%]%n@%M:%>/%/\n%R%x%#%[%033[0m%] '
On Mon, Mar 25, 2024 at 4:30 AM Jelte Fennema-Nio <postgres@jeltef.nl> wrote: > That problem seems easy to address by adding a newline into the > default prompt. Ugh. Please, no! -- Robert Haas EDB: http://www.enterprisedb.com
On Mon, 25 Mar 2024 at 14:06, Robert Haas <robertmhaas@gmail.com> wrote: > On Mon, Mar 25, 2024 at 4:30 AM Jelte Fennema-Nio <postgres@jeltef.nl> wrote: > > That problem seems easy to address by adding a newline into the > > default prompt. > > Ugh. Please, no! I guess it's partially a matter of taste, but personally I'm never going back to a single line prompt. It's so nice for zoomed-in demos that your SQL queries don't get broken up.
On Mon, 25 Mar 2024 at 14:06, Robert Haas <robertmhaas@gmail.com> wrote:
> On Mon, Mar 25, 2024 at 4:30 AM Jelte Fennema-Nio <postgres@jeltef.nl> wrote:
> > That problem seems easy to address by adding a newline into the
> > default prompt.
>
> Ugh. Please, no!
I guess it's partially a matter of taste, but personally I'm never
going back to a single line prompt. It's so nice for zoomed-in demos
that your SQL queries don't get broken up.
On Tue, Mar 26, 2024 at 7:14 AM Andrew Dunstan <andrew@dunslane.net> wrote: > > > > On Mon, Mar 25, 2024 at 9:14 AM Jelte Fennema-Nio <postgres@jeltef.nl> wrote: >> >> On Mon, 25 Mar 2024 at 14:06, Robert Haas <robertmhaas@gmail.com> wrote: >> > On Mon, Mar 25, 2024 at 4:30 AM Jelte Fennema-Nio <postgres@jeltef.nl> wrote: >> > > That problem seems easy to address by adding a newline into the >> > > default prompt. >> > >> > Ugh. Please, no! >> >> I guess it's partially a matter of taste, but personally I'm never >> going back to a single line prompt. It's so nice for zoomed-in demos >> that your SQL queries don't get broken up. > > > > Very much a matter of taste. I knew when I saw your suggestion there would be some kickback. If horizontal space is ata premium vertical space is doubly so, I suspect. > the change (session username in default psql prompt) is quite visible, maybe this time we can conduct a poll, but in a way the poll can reach more people?