pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedExternal psql editor
26+ messages / 10 participants
[nested] [flat]
* External psql editor
@ 2022-04-29 15:55 Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 16:53 ` Re: External psql editor Francisco Olarte <folarte@peoplecall.com>
0 siblings, 2 replies; 26+ messages in thread
From: Rich Shepard @ 2022-04-29 15:55 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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.)
Regards,
Rich
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
@ 2022-04-29 16:42 ` Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
1 sibling, 1 reply; 26+ messages in thread
From: Jan Wieck @ 2022-04-29 16:42 UTC (permalink / raw)
To: Rich Shepard <rshepard@appl-ecosys.com>; pgsql-general@lists.postgresql.org
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
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
@ 2022-04-29 17:13 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
0 siblings, 1 reply; 26+ messages in thread
From: Rich Shepard @ 2022-04-29 17:13 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Fri, 29 Apr 2022, Jan Wieck wrote:
> 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.
Jan,
Ah! That wasn't mentioned in the thread I read.
> 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.
Can I set it before entering any command or better yet, when I invoke psql?
Thanks very much,
Rich
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
@ 2022-04-29 17:35 ` Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 19:50 ` Re: External psql editor Mladen Gogala <gogala.mladen@gmail.com>
0 siblings, 2 replies; 26+ messages in thread
From: Jan Wieck @ 2022-04-29 17:35 UTC (permalink / raw)
To: Rich Shepard <rshepard@appl-ecosys.com>; pgsql-general@lists.postgresql.org
On 4/29/22 13:13, Rich Shepard wrote:
>> 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.
>
> Can I set it before entering any command or better yet, when I invoke psql?
Not that I know of. \e starts the external editor and you have to save
and exit that editor to get back to psql in order to execute it. IMHO
the whole construct has very limited usability.
Regards, Jan
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
@ 2022-04-29 18:10 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 18:21 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 19:27 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
1 sibling, 2 replies; 26+ messages in thread
From: Rich Shepard @ 2022-04-29 18:10 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Fri, 29 Apr 2022, Jan Wieck wrote:
> Not that I know of. \e starts the external editor and you have to save and
> exit that editor to get back to psql in order to execute it. IMHO the
> whole construct has very limited usability.
Jan,
I tried, unsuccessily, to use \e. Entering it while a command is displayed
does nothing. So I'm doing something wrong.
I'll continue using character-by-character movement.
Thanks again,
Rich
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
@ 2022-04-29 18:21 ` Jan Wieck <jan@wi3ck.info>
2022-04-29 20:17 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
1 sibling, 1 reply; 26+ messages in thread
From: Jan Wieck @ 2022-04-29 18:21 UTC (permalink / raw)
To: Rich Shepard <rshepard@appl-ecosys.com>; pgsql-general@lists.postgresql.org
On 4/29/22 14:10, Rich Shepard wrote:
> I tried, unsuccessily, to use \e. Entering it while a command is displayed
> does nothing. So I'm doing something wrong.
Did you hit Enter after \e ?
Regards, Jan
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 18:21 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
@ 2022-04-29 20:17 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 20:31 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 20:33 ` Re: External psql editor David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 2 replies; 26+ messages in thread
From: Rich Shepard @ 2022-04-29 20:17 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Fri, 29 Apr 2022, Jan Wieck wrote:
> Did you hit Enter after \e ?
Jan,
Yes. For example, I put a previous command at the prompt to be modified. It
began with 'insert ...' so I added an initial \e to the command. psql told
me that \einsert is not a valid command after I pressed the [Enter] key.
Rich
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 18:21 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 20:17 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
@ 2022-04-29 20:31 ` Jan Wieck <jan@wi3ck.info>
2022-04-29 21:12 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
1 sibling, 1 reply; 26+ messages in thread
From: Jan Wieck @ 2022-04-29 20:31 UTC (permalink / raw)
To: Rich Shepard <rshepard@appl-ecosys.com>; pgsql-general@lists.postgresql.org
On 4/29/22 16:17, Rich Shepard wrote:
> On Fri, 29 Apr 2022, Jan Wieck wrote:
>
>> Did you hit Enter after \e ?
>
> Jan,
>
> Yes. For example, I put a previous command at the prompt to be modified. It
> began with 'insert ...' so I added an initial \e to the command. psql told
> me that \einsert is not a valid command after I pressed the [Enter] key.
It is the other way around, like in
postgres-# select now()\e
That puts "select now()" into vi(1) for me.
Regards, Jan
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 18:21 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 20:17 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 20:31 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
@ 2022-04-29 21:12 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 22:09 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
0 siblings, 1 reply; 26+ messages in thread
From: Rich Shepard @ 2022-04-29 21:12 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Fri, 29 Apr 2022, Jan Wieck wrote:
> It is the other way around, like in
> postgres-# select now()\e
Jan,
That does make a difference. Now I'm learning how to end the edit and return
from joe to the psql shell. The [Enter] key wraps the long line; probably
C-x will do the job.
Many thanks,
Rich
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 18:21 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 20:17 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 20:31 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 21:12 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
@ 2022-04-29 22:09 ` Rich Shepard <rshepard@appl-ecosys.com>
0 siblings, 0 replies; 26+ messages in thread
From: Rich Shepard @ 2022-04-29 22:09 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Fri, 29 Apr 2022, Rich Shepard wrote:
> ... probably C-x will do the job.
Actually, it's C-k x, the usual joe save command.
My thanks to all because this new skill is saving me much time and effort.
Regards,
Rich
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 18:21 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 20:17 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
@ 2022-04-29 20:33 ` David G. Johnston <david.g.johnston@gmail.com>
2022-04-29 21:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
1 sibling, 1 reply; 26+ messages in thread
From: David G. Johnston @ 2022-04-29 20:33 UTC (permalink / raw)
To: Rich Shepard <rshepard@appl-ecosys.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
On Fri, Apr 29, 2022 at 1:17 PM Rich Shepard <rshepard@appl-ecosys.com>
wrote:
> On Fri, 29 Apr 2022, Jan Wieck wrote:
>
> > Did you hit Enter after \e ?
>
> Jan,
>
> Yes. For example, I put a previous command at the prompt to be modified. It
> began with 'insert ...' so I added an initial \e to the command. psql told
> me that \einsert is not a valid command after I pressed the [Enter] key.
>
You type "insert", realize you want an editor for this, hit enter
(multi-line mode is psql), type \e, hit enter again, your editor appears
with "insert" already in place from the query buffer. Upon returning you
are given a new buffer with the contents of whatever you typed into the
editor pasted in.
David J.
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 18:21 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 20:17 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 20:33 ` Re: External psql editor David G. Johnston <david.g.johnston@gmail.com>
@ 2022-04-29 21:13 ` Rich Shepard <rshepard@appl-ecosys.com>
0 siblings, 0 replies; 26+ messages in thread
From: Rich Shepard @ 2022-04-29 21:13 UTC (permalink / raw)
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
On Fri, 29 Apr 2022, David G. Johnston wrote:
> You type "insert", realize you want an editor for this, hit enter
> (multi-line mode is psql), type \e, hit enter again, your editor appears
> with "insert" already in place from the query buffer. Upon returning you
> are given a new buffer with the contents of whatever you typed into the
> editor pasted in.
Thank you, David.
Rich
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
@ 2022-04-29 19:27 ` Reid Thompson <jreidthompson@nc.rr.com>
2022-04-29 20:21 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
1 sibling, 1 reply; 26+ messages in thread
From: Reid Thompson @ 2022-04-29 19:27 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Fri, 2022-04-29 at 11:10 -0700, Rich Shepard wrote:
> On Fri, 29 Apr 2022, Jan Wieck wrote:
>
> > Not that I know of. \e starts the external editor and you have to
> > save and
> > exit that editor to get back to psql in order to execute it. IMHO
> > the
> > whole construct has very limited usability.
>
> Jan,
>
> I tried, unsuccessily, to use \e. Entering it while a command is
> displayed
> does nothing. So I'm doing something wrong.
>
> I'll continue using character-by-character movement.
>
> Thanks again,
>
> Rich
>
>
https://linuxgazette.net/issue14/bashtip.html may of of use.
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 19:27 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
@ 2022-04-29 20:21 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 18:57 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
0 siblings, 1 reply; 26+ messages in thread
From: Rich Shepard @ 2022-04-29 20:21 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Fri, 29 Apr 2022, Reid Thompson wrote:
> https://linuxgazette.net/issue14/bashtip.html may of of use.
Reid,
I've had no issues using joe in any v.t. running an application (e.g.,
alpine) or by itself. Apparently, psql is different.
Rich
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 19:27 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-04-29 20:21 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
@ 2022-05-02 18:57 ` Reid Thompson <jreidthompson@nc.rr.com>
2022-05-02 19:18 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
0 siblings, 1 reply; 26+ messages in thread
From: Reid Thompson @ 2022-05-02 18:57 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Fri, 2022-04-29 at 13:21 -0700, Rich Shepard wrote:
> On Fri, 29 Apr 2022, Reid Thompson wrote:
>
> > https://linuxgazette.net/issue14/bashtip.html may of of use.
>
> Reid,
>
> I've had no issues using joe in any v.t. running an application
> (e.g.,
> alpine) or by itself. Apparently, psql is different.
>
> Rich
>
>
I believe that psql also uses readline, so my thought was that maybe
these instructions could enable you to map the 'move' keystrokes that
you're familiar with to be used while on the psql command line. A very
quick test seems to indicate that you can.
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 19:27 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-04-29 20:21 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 18:57 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
@ 2022-05-02 19:18 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 21:27 ` Re: External psql editor Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 26+ messages in thread
From: Rich Shepard @ 2022-05-02 19:18 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Mon, 2 May 2022, Reid Thompson wrote:
>> Apparently, psql is different.
> I believe that psql also uses readline, so my thought was that maybe these
> instructions could enable you to map the 'move' keystrokes that you're
> familiar with to be used while on the psql command line. A very quick test
> seems to indicate that you can.
Reid,
Nope. No difference. Learning to put the '\e' at the end of the command line
rather than at the head did the job.
All's well.
Thanks,
Rich
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 19:27 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-04-29 20:21 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 18:57 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-05-02 19:18 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
@ 2022-05-02 21:27 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-05-02 21:31 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 22:41 ` Re: External psql editor Mladen Gogala <gogala.mladen@gmail.com>
2022-05-03 05:49 ` Re: External psql editor Steve Litt <slitt@troubleshooters.com>
0 siblings, 3 replies; 26+ messages in thread
From: Tom Lane @ 2022-05-02 21:27 UTC (permalink / raw)
To: Rich Shepard <rshepard@appl-ecosys.com>; +Cc: pgsql-general@lists.postgresql.org
Rich Shepard <rshepard@appl-ecosys.com> writes:
> On Mon, 2 May 2022, Reid Thompson wrote:
>> I believe that psql also uses readline, so my thought was that maybe these
>> instructions could enable you to map the 'move' keystrokes that you're
>> familiar with to be used while on the psql command line. A very quick test
>> seems to indicate that you can.
> Nope. No difference.
Perhaps your psql is built against libedit rather than readline.
regards, tom lane
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 19:27 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-04-29 20:21 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 18:57 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-05-02 19:18 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 21:27 ` Re: External psql editor Tom Lane <tgl@sss.pgh.pa.us>
@ 2022-05-02 21:31 ` Rich Shepard <rshepard@appl-ecosys.com>
2 siblings, 0 replies; 26+ messages in thread
From: Rich Shepard @ 2022-05-02 21:31 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Mon, 2 May 2022, Tom Lane wrote:
> Perhaps your psql is built against libedit rather than readline.
Tom,
Could be I use the SlackBuilds.org build script.
Regards,
Rich
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 19:27 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-04-29 20:21 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 18:57 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-05-02 19:18 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 21:27 ` Re: External psql editor Tom Lane <tgl@sss.pgh.pa.us>
@ 2022-05-02 22:41 ` Mladen Gogala <gogala.mladen@gmail.com>
2 siblings, 0 replies; 26+ messages in thread
From: Mladen Gogala @ 2022-05-02 22:41 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 5/2/22 17:27, Tom Lane wrote:
> Rich Shepard<rshepard@appl-ecosys.com> writes:
>> On Mon, 2 May 2022, Reid Thompson wrote:
>>> I believe that psql also uses readline, so my thought was that maybe these
>>> instructions could enable you to map the 'move' keystrokes that you're
>>> familiar with to be used while on the psql command line. A very quick test
>>> seems to indicate that you can.
>> Nope. No difference.
> Perhaps your psql is built against libedit rather than readline.
>
> regards, tom lane
>
>
That is easy enough to determine:
mgogala@umajor ~]$ ldd `which psql`
linux-vdso.so.1 (0x00007ffded951000)
libpq.so.private13-5 => /lib64/libpq.so.private13-5
(0x00007ff145284000)
_*libreadline.so.8 => /lib64/libreadline.so.8 (0x00007ff14522c000)*_
libm.so.6 => /lib64/libm.so.6 (0x00007ff145150000)
libc.so.6 => /lib64/libc.so.6 (0x00007ff144f49000)
libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007ff144eac000)
libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007ff144bbe000)
libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007ff144b65000)
libldap_r-2.4.so.2 => /lib64/libldap_r-2.4.so.2 (0x00007ff144b09000)
libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007ff144ada000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff14539a000)
libz.so.1 => /lib64/libz.so.1 (0x00007ff144ac0000)
libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007ff1449e2000)
libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007ff1449ca000)
libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007ff1449c1000)
libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007ff1449b0000)
libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007ff1449a9000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007ff144995000)
liblber-2.4.so.2 => /lib64/liblber-2.4.so.2 (0x00007ff144982000)
libsasl2.so.3 => /lib64/libsasl2.so.3 (0x00007ff144962000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007ff144935000)
libcrypt.so.2 => /lib64/libcrypt.so.2 (0x00007ff1448fb000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007ff144864000)
[mgogala@umajor ~]$
Regards
--
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 19:27 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-04-29 20:21 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 18:57 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-05-02 19:18 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 21:27 ` Re: External psql editor Tom Lane <tgl@sss.pgh.pa.us>
@ 2022-05-03 05:49 ` Steve Litt <slitt@troubleshooters.com>
2022-05-03 06:36 ` Re: External psql editor Peter J. Holzer <hjp-pgsql@hjp.at>
2 siblings, 1 reply; 26+ messages in thread
From: Steve Litt @ 2022-05-03 05:49 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Tom Lane said on Mon, 02 May 2022 17:27:15 -0400
>Rich Shepard <rshepard@appl-ecosys.com> writes:
>> On Mon, 2 May 2022, Reid Thompson wrote:
>>> I believe that psql also uses readline, so my thought was that
>>> maybe these instructions could enable you to map the 'move'
>>> keystrokes that you're familiar with to be used while on the psql
>>> command line. A very quick test seems to indicate that you can.
>
>> Nope. No difference.
>
>Perhaps your psql is built against libedit rather than readline.
If this is indeed true, he can give his psql readline capabilities by
installing rlwrap and performing the following command:
rlwrap psql
HTH,
SteveT
Steve Litt
March 2022 featured book: Making Mental Models: Advanced Edition
http://www.troubleshooters.com/mmm
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 19:27 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-04-29 20:21 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 18:57 ` Re: External psql editor Reid Thompson <jreidthompson@nc.rr.com>
2022-05-02 19:18 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 21:27 ` Re: External psql editor Tom Lane <tgl@sss.pgh.pa.us>
2022-05-03 05:49 ` Re: External psql editor Steve Litt <slitt@troubleshooters.com>
@ 2022-05-03 06:36 ` Peter J. Holzer <hjp-pgsql@hjp.at>
0 siblings, 0 replies; 26+ messages in thread
From: Peter J. Holzer @ 2022-05-03 06:36 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2022-05-03 01:49:41 -0400, Steve Litt wrote:
> Tom Lane said on Mon, 02 May 2022 17:27:15 -0400
[changing keybindings doesn't work]
> >Perhaps your psql is built against libedit rather than readline.
>
> If this is indeed true, he can give his psql readline capabilities by
> installing rlwrap and performing the following command:
While rlwrap is useful sometimes, I suggest reading the manual for
libedit might be a better option.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
@ 2022-04-29 19:50 ` Mladen Gogala <gogala.mladen@gmail.com>
2022-04-29 19:58 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 22:45 ` Re: External psql editor Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 2 replies; 26+ messages in thread
From: Mladen Gogala @ 2022-04-29 19:50 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 4/29/22 13:35, Jan Wieck wrote:
> Not that I know of. \e starts the external editor and you have to save
> and exit that editor to get back to psql in order to execute it. IMHO
> the whole construct has very limited usability.
>
>
> Regards, Jan
Is there a way to define the name of the temporary file created by \e
command? I'd like to name it "afiedt.buf", not for sentimental reasons.
I already have a cron job that cleans afiedt.buf from my home directory
every hour and having psql name temporary file like that would simplify
the cleaning process. The name comes from another database with the same
editor construct as \e. I am actually quite used to that.
Regards
--
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 19:50 ` Re: External psql editor Mladen Gogala <gogala.mladen@gmail.com>
@ 2022-04-29 19:58 ` Jan Wieck <jan@wi3ck.info>
1 sibling, 0 replies; 26+ messages in thread
From: Jan Wieck @ 2022-04-29 19:58 UTC (permalink / raw)
To: Mladen Gogala <gogala.mladen@gmail.com>; pgsql-general@lists.postgresql.org
On 4/29/22 15:50, Mladen Gogala wrote:
> Is there a way to define the name of the temporary file created by \e
> command? I'd like to name it "afiedt.buf", not for sentimental reasons.
> I already have a cron job that cleans afiedt.buf from my home directory
> every hour and having psql name temporary file like that would simplify
> the cleaning process. The name comes from another database with the same
> editor construct as \e. I am actually quite used to that.
I honestly don't know. However, psql is reading back that temporary file
and removes it when you exit the external editor, so there is no use for
that cron job here. This is similar to the behavior of other systems
like "virsh edit DOM" for example.
Regards, Jan
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Re: External psql editor Jan Wieck <jan@wi3ck.info>
2022-04-29 19:50 ` Re: External psql editor Mladen Gogala <gogala.mladen@gmail.com>
@ 2022-04-29 22:45 ` Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 0 replies; 26+ messages in thread
From: Adrian Klaver @ 2022-04-29 22:45 UTC (permalink / raw)
To: Mladen Gogala <gogala.mladen@gmail.com>; pgsql-general@lists.postgresql.org
On 4/29/22 12:50 PM, Mladen Gogala wrote:
> On 4/29/22 13:35, Jan Wieck wrote:
>> Not that I know of. \e starts the external editor and you have to save
>> and exit that editor to get back to psql in order to execute it. IMHO
>> the whole construct has very limited usability.
>>
>>
>> Regards, Jan
>
> Is there a way to define the name of the temporary file created by \e
> command? I'd like to name it "afiedt.buf", not for sentimental reasons.
> I already have a cron job that cleans afiedt.buf from my home directory
> every hour and having psql name temporary file like that would simplify
> the cleaning process. The name comes from another database with the same
> editor construct as \e. I am actually quite used to that.
If want to do something like that you would need to do(using VIM here):
\e
select 1;
:w afiedt.buf
or
:wq afiedt.buf
Assuming you closed the editor you could pick up the file later by doing.
\e afiedt.buf
>
> Regards
>
> --
> Mladen Gogala
> Database Consultant
> Tel: (347) 321-1217
> https://dbwhisperer.wordpress.com
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
@ 2022-04-29 16:53 ` Francisco Olarte <folarte@peoplecall.com>
2022-04-29 17:18 ` Re: External psql editor Rich Shepard <rshepard@appl-ecosys.com>
1 sibling, 1 reply; 26+ messages in thread
From: Francisco Olarte @ 2022-04-29 16:53 UTC (permalink / raw)
To: Rich Shepard <rshepard@appl-ecosys.com>; +Cc: pgsql-general@lists.postgresql.org
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.
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: External psql editor
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:53 ` Re: External psql editor Francisco Olarte <folarte@peoplecall.com>
@ 2022-04-29 17:18 ` Rich Shepard <rshepard@appl-ecosys.com>
0 siblings, 0 replies; 26+ messages in thread
From: Rich Shepard @ 2022-04-29 17:18 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Fri, 29 Apr 2022, Francisco Olarte wrote:
> 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) ).
Francisco,
Joe can also be configured to use emacs chords which lets my fingers use the
same keys in both editors. :-)
> 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.
>
> 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 ).
Good information. Thanks. I'll dig into joe and see what's possible.
Regards,
Rich
^ permalink raw reply [nested|flat] 26+ messages in thread
end of thread, other threads:[~2022-05-03 06:36 UTC | newest]
Thread overview: 26+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-04-29 15:55 External psql editor Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 16:42 ` Jan Wieck <jan@wi3ck.info>
2022-04-29 17:13 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 17:35 ` Jan Wieck <jan@wi3ck.info>
2022-04-29 18:10 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 18:21 ` Jan Wieck <jan@wi3ck.info>
2022-04-29 20:17 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 20:31 ` Jan Wieck <jan@wi3ck.info>
2022-04-29 21:12 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 22:09 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 20:33 ` David G. Johnston <david.g.johnston@gmail.com>
2022-04-29 21:13 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-04-29 19:27 ` Reid Thompson <jreidthompson@nc.rr.com>
2022-04-29 20:21 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 18:57 ` Reid Thompson <jreidthompson@nc.rr.com>
2022-05-02 19:18 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 21:27 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-05-02 21:31 ` Rich Shepard <rshepard@appl-ecosys.com>
2022-05-02 22:41 ` Mladen Gogala <gogala.mladen@gmail.com>
2022-05-03 05:49 ` Steve Litt <slitt@troubleshooters.com>
2022-05-03 06:36 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2022-04-29 19:50 ` Mladen Gogala <gogala.mladen@gmail.com>
2022-04-29 19:58 ` Jan Wieck <jan@wi3ck.info>
2022-04-29 22:45 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-04-29 16:53 ` Francisco Olarte <folarte@peoplecall.com>
2022-04-29 17:18 ` Rich Shepard <rshepard@appl-ecosys.com>
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