Re: External psql editor - Mailing list pgsql-general

From Francisco Olarte
Subject Re: External psql editor
Date
Msg-id CA+bJJbzhqdaK3MFaGCJDUosvnph4Z1YjN4wXGtLfyzwZzayLug@mail.gmail.com
Whole thread Raw
In response to External psql editor  (Rich Shepard <rshepard@appl-ecosys.com>)
Responses Re: External psql editor  (Rich Shepard <rshepard@appl-ecosys.com>)
List pgsql-general
Hi Rich:

On Fri, 29 Apr 2022 at 17:55, Rich Shepard <rshepard@appl-ecosys.com> wrote:
> I do all my postgres work using the psql shell. Editing a command reguires
> moving character-by-character and I'd like to use my small text editor (joe)
> because it allows more control over line movement.

I do a similar thing, but normally edit queries in an editor window
and just use selection or clipboard to paste them into the xterm where
I have psql running. I also used joe a lot ( its key sequences where
easy coming from wordstar(cp/m->msdos) ).

> A web search found a stackexchange thread that suggested adding to
> ~/.bash_profile the line:
> export PSQL_EDITOR=/usr/bin/joe
> so I did this yesterday.
>
> Today I've learned that the keyboard chords I use in joe in other
> applications aren't working here. For example, C-w should delete the word to
> the right of the point (cursor location). It doesn't. Instead, it deletes
> from the cursor postion to the head of the line. C-x doesn't move the cursor
> one word to the right, but cancels the command.

What do you mean by "here"? IIRC PSQL_EDITOR sets the editor for \e,
not for the psql command line. For that you could try writing a
binding for readline ( which you could also use in bash if you like
them ) with the joe keyseqs, but I fear it's editing model is a nit
different.

I've done "PSQL_EDITOR=joe psql" to refresh my memory and it is in
fact as I remembered.

> Is there a way for me to specify use of joe at the psql command line? (I'd
> use emacs but that's gross overkill.)

The use of joe AS EDITOR for a single command can be done with the
above method. The use of joe keys for editting the normal psql line
would probably require readline wizardry.

I've read joe has slave shell sessions. Other thing you could try (
I've done it with emacs shell mode ) is use that, but I fear it only
works well with single line queries. Or look if it has some kind of
sql modes ( interactive sql, not sql-script-syntax-highlight ).


Francisco Olarte.



pgsql-general by date:

Previous
From: Jan Wieck
Date:
Subject: Re: External psql editor
Next
From: Rich Shepard
Date:
Subject: Re: External psql editor