From: Jan Wieck <jan@wi3ck.info>
To: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: External psql editor
Date: Fri, 29 Apr 2022 12:42:44 -0400
Message-ID: <7fef2d5f-6698-0bb5-11fe-ffd042a24ab1@wi3ck.info> (raw)
In-Reply-To: <edf1cfa4-35bf-66bf-4de2-7a3bbcb6c5e4@appl-ecosys.com>
References: <edf1cfa4-35bf-66bf-4de2-7a3bbcb6c5e4@appl-ecosys.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: jan@wi3ck.info, rshepard@appl-ecosys.com
Subject: Re: External psql editor
In-Reply-To: <7fef2d5f-6698-0bb5-11fe-ffd042a24ab1@wi3ck.info>
References: <edf1cfa4-35bf-66bf-4de2-7a3bbcb6c5e4@appl-ecosys.com> <7fef2d5f-6698-0bb5-11fe-ffd042a24ab1@wi3ck.info>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox