Re: Invisible PROMPT2

From: Maxence Ahlouche <maxence(dot)ahlouche(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: Re: Invisible PROMPT2
Date: 2019-11-27 15:30:12
Message-ID: CAJeaomVyLSP_Wj=0FtYNTuoopWHyFarhUtYKDHs0HHv+b=N9sA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I noticed that this patch does not work when PROMPT1 contains a new line,
since the whole length of PROMPT1 is taken into account for the length of
%w.
Attached screenshot shows the issue on my psql, with the following PROMPT
variables (colors edited out for readability):

\set PROMPT1 '\n[pid:%p] %n :: %`hostname`:%> ‹%/› \n› '
\set PROMPT2 '%w'

Notice in the screenshot that just after inputting a newline, my cursor is
far to the right.
The length of %w should probably be computed starting from the last newline
in PROMPT1.

I could technically get rid of my newline, but since my prompt can get
pretty long, i like the comfort of having my first line of sql start right
at the left of my terminal.

Also attached is a trivial patch to fix this issue, which I have not
extensively tested (works for me at least), and might not be the right way
to do it, but it's a start.
Otherwise, nice feature, I like it!

Regards,
Maxence

Attachment Content-Type Size
image/png 26.2 KB
psql_prompt.patch text/x-patch 776 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Konstantin Knizhnik 2019-11-27 15:38:45 Re: Why JIT speed improvement is so modest?
Previous Message Tomas Vondra 2019-11-27 15:28:18 Re: pglz performance