Re: External psql editor

From: Jan Wieck <jan(at)wi3ck(dot)info>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: External psql editor
Date: 2022-04-29 16:42:44
Message-ID: 7fef2d5f-6698-0bb5-11fe-ffd042a24ab1@wi3ck.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 4/29/22 11:55, Rich Shepard 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.
>
> 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.
>
> 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.)

What you are missing is that even though the PSQL_EDITOR env variable is
set, psql itself doesn't emulate that editor's behavior natively. You
need to actually launch the editor (possibly while having a partial
query in the buffer) with the \e command.

While in psql, type \e and Enter. You will have the current query buffer
in the editor. You can do this at the end of a partial (not yet
semicolon terminated) query.

Best Regards, Jan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Olarte 2022-04-29 16:53:43 Re: External psql editor
Previous Message Rich Shepard 2022-04-29 15:55:37 External psql editor