Skip site navigation (1) Skip section navigation (2)

Re: Changing the continuation-line prompt in psql?

From: Christopher Browne <cbbrowne(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Changing the continuation-line prompt in psql?
Date: 2011-04-29 16:45:44
Message-ID: BANLkTinsQ9Ra+CSJS0SK4JXU5uK-sO7kyA@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Fri, Apr 29, 2011 at 12:17 PM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> Excerpts from David E. Wheeler's message of vie abr 29 13:04:35 -0300 2011:
>> On Apr 29, 2011, at 8:22 AM, Tom Lane wrote:
>>
>> > AFAICT the initial prompt is always "mysql> ", so they don't have to
>> > think hard about how many spaces to insert to make it line up.  But
>> > we could certainly invent a prompt escape that means "as many spaces
>> > as there are characters in the current DB name".  (Or maybe we should
>> > try to generalize that idea, so you could get similar behavior for
>> > custom prompts involving usernames etc?)
>>
>> +1 I like this idea, so the prompt might by default be
>>
>>     postgres=>
>>             +>

That's certainly a reasonable sort of start.

It seems like pretty serious bikeshedding to try to come up with an
operator to express "do as many of character X as the length of
variable $FOO".  I know people have been hacking on zsh and Bash to do
wacky things like that - I somewhat doubt that we really want to go
too far down that road.  (I'd be about equally excited about
integrating an APL into psql.  Of course, I'm watching
<https://github.com/kevinlawler/kona>, which is an ASCII-ized APL
clone, so that mightn't be the thing I'd MOST vigorously argue against
;-).)

The "bike shedding" that I'd rather have would involve enclosing
prompts with /* comments */ so that cut'n'paste could be expected to
generate output that could run, without further editing, in another
psql session.  Mind you, whenever I have configured such, I have been
unhappy at how wide that makes the prompt and at the loss of screen
space.

I'm not totally appalled at the thought of subsequent lines not being
perfectly aligned with the first one - frequently, the first line of a
multiline query is differently indented or has different proper policy
(e.g. - CREATE OR REPLACE FUNCTION *can* safely differ from the body
of the function).

I think I could readily live with PROMPT2="   +>", all in all.
-- 
When confronted by a difficult problem, solve it by reducing it to the
question, "How would the Lone Ranger handle this?"

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2011-04-29 17:14:53
Subject: Re: BUG #5998: CLUSTER and "ERROR: missing chunk number 0 for toast value"
Previous:From: Alvaro HerreraDate: 2011-04-29 16:17:47
Subject: Re: Changing the continuation-line prompt in psql?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group