public inbox for [email protected]
help / color / mirror / Atom feedRe: psql command line editing
14+ messages / 7 participants
[nested] [flat]
* Re: psql command line editing
@ 2025-02-12 18:55 Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
0 siblings, 1 reply; 14+ messages in thread
From: Ron Johnson @ 2025-02-12 18:55 UTC (permalink / raw)
To: pgsql-general
On Wed, Feb 12, 2025 at 1:50 PM Rich Shepard <[email protected]>
wrote:
> My web searches suggest that using the psql command line I'm limited to
> moving the cursor one character at a time. Is there a way to use a small
> editor, e.g., joe on linux, to move by words or to the begining and end of
> the line?
The PGDG prebuilt packages are built with libreadline. Thus, if that's how
you installed psql, Home, End, Ctrl-Left, Ctrl-Right and Ctrl-w should work.
--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
@ 2025-02-12 19:29 ` Tom Lane <[email protected]>
2025-02-12 19:44 ` Re: psql command line editing Rich Shepard <[email protected]>
2025-02-12 20:03 ` Re: psql command line editing Ron Johnson <[email protected]>
0 siblings, 2 replies; 14+ messages in thread
From: Tom Lane @ 2025-02-12 19:29 UTC (permalink / raw)
To: Ron Johnson <[email protected]>; +Cc: Rich Shepard <[email protected]>; pgsql-general
Ron Johnson <[email protected]> writes:
> On Wed, Feb 12, 2025 at 1:50 PM Rich Shepard <[email protected]>
> wrote:
>> My web searches suggest that using the psql command line I'm limited to
>> moving the cursor one character at a time. Is there a way to use a small
>> editor, e.g., joe on linux, to move by words or to the begining and end of
>> the line?
> The PGDG prebuilt packages are built with libreadline. Thus, if that's how
> you installed psql, Home, End, Ctrl-Left, Ctrl-Right and Ctrl-w should work.
On my machine, Ctrl-Left/Right don't seem to do anything, but
the usual Emacs combinations Ctrl-A, Ctrl-E, Escape-B, Escape-F
and so on work in psql. I don't believe I did anything special
to configure that. Check your local readline documentation.
As Adrian notes, there's also \e, which is good for entering
or editing multi-line queries.
regards, tom lane
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
@ 2025-02-12 19:44 ` Rich Shepard <[email protected]>
2025-02-12 19:50 ` Re: psql command line editing Adrian Klaver <[email protected]>
2025-02-12 22:09 ` Re: psql command line editing Ben Hancock <[email protected]>
1 sibling, 2 replies; 14+ messages in thread
From: Rich Shepard @ 2025-02-12 19:44 UTC (permalink / raw)
To: pgsql-general
On Wed, 12 Feb 2025, Tom Lane wrote:
> On my machine, Ctrl-Left/Right don't seem to do anything, but the usual
> Emacs combinations Ctrl-A, Ctrl-E, Escape-B, Escape-F and so on work in
> psql. I don't believe I did anything special to configure that. Check your
> local readline documentation.
Tom,
I run psql from a urxvt virtual console, not emacs (which is where I write
scripts.)
> As Adrian notes, there's also \e, which is good for entering
> or editing multi-line queries.
Often when updating table rows I'll modify one string and the row ID so I'll
learn to use \e to move around the string.
Many thanks,
Rich
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
2025-02-12 19:44 ` Re: psql command line editing Rich Shepard <[email protected]>
@ 2025-02-12 19:50 ` Adrian Klaver <[email protected]>
2025-02-12 19:54 ` Re: psql command line editing Rich Shepard <[email protected]>
1 sibling, 1 reply; 14+ messages in thread
From: Adrian Klaver @ 2025-02-12 19:50 UTC (permalink / raw)
To: Rich Shepard <[email protected]>; pgsql-general
On 2/12/25 11:44, Rich Shepard wrote:
> On Wed, 12 Feb 2025, Tom Lane wrote:
>
>> On my machine, Ctrl-Left/Right don't seem to do anything, but the usual
>> Emacs combinations Ctrl-A, Ctrl-E, Escape-B, Escape-F and so on work in
>> psql. I don't believe I did anything special to configure that. Check
>> your
>> local readline documentation.
>
> Tom,
>
> I run psql from a urxvt virtual console, not emacs (which is where I write
> scripts.)
The point Tom was making is that psql uses readline for it's editing
positioning and that for him Emacs movement commands work in psql.
>
>> As Adrian notes, there's also \e, which is good for entering
>> or editing multi-line queries.
>
> Often when updating table rows I'll modify one string and the row ID so
> I'll
> learn to use \e to move around the string.
>
> Many thanks,
>
> Rich
>
>
--
Adrian Klaver
[email protected]
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
2025-02-12 19:44 ` Re: psql command line editing Rich Shepard <[email protected]>
2025-02-12 19:50 ` Re: psql command line editing Adrian Klaver <[email protected]>
@ 2025-02-12 19:54 ` Rich Shepard <[email protected]>
0 siblings, 0 replies; 14+ messages in thread
From: Rich Shepard @ 2025-02-12 19:54 UTC (permalink / raw)
To: pgsql-general
On Wed, 12 Feb 2025, Adrian Klaver wrote:
> The point Tom was making is that psql uses readline for it's editing
> positioning and that for him Emacs movement commands work in psql.
Adrian,
Thanks for clarifying; the emacs commands work for me, too, in psql.
Regards,
Rich
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
2025-02-12 19:44 ` Re: psql command line editing Rich Shepard <[email protected]>
@ 2025-02-12 22:09 ` Ben Hancock <[email protected]>
1 sibling, 0 replies; 14+ messages in thread
From: Ben Hancock @ 2025-02-12 22:09 UTC (permalink / raw)
To: pgsql-general; +Cc: Rich Shepard <[email protected]>
On 2/12/2025 11:44, Rich Shepard wrote:
> I run psql from a urxvt virtual console, not emacs (which is where I
> write scripts.)
As with everything in Emacs, there's a mode for that.
In case you're not aware of it, sql-mode allows you not only to interact
with psql from within Emacs, but also to write SQL queries in a buffer
and then send the whole buffer or the region.
It's not documented in the info pages, but from within Emacs, one of
these should get you started:
C-h P sql
M-x sql-help
Or just do: M-x sql-postgres
- Ben
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
@ 2025-02-12 20:03 ` Ron Johnson <[email protected]>
2025-02-12 20:29 ` Re: psql command line editing Adrian Klaver <[email protected]>
2025-02-12 21:17 ` Re: psql command line editing Rob Sargent <[email protected]>
1 sibling, 2 replies; 14+ messages in thread
From: Ron Johnson @ 2025-02-12 20:03 UTC (permalink / raw)
To: pgsql-general
On Wed, Feb 12, 2025 at 2:29 PM Tom Lane <[email protected]> wrote:
> Ron Johnson <[email protected]> writes:
> > On Wed, Feb 12, 2025 at 1:50 PM Rich Shepard <[email protected]>
> > wrote:
> >> My web searches suggest that using the psql command line I'm limited to
> >> moving the cursor one character at a time. Is there a way to use a small
> >> editor, e.g., joe on linux, to move by words or to the begining and end
> of
> >> the line?
>
> > The PGDG prebuilt packages are built with libreadline. Thus, if that's
> how
> > you installed psql, Home, End, Ctrl-Left, Ctrl-Right and Ctrl-w should
> work.
>
> On my machine, Ctrl-Left/Right don't seem to do anything, but
> the usual Emacs combinations Ctrl-A, Ctrl-E, Escape-B, Escape-F
> and so on work in psql. I don't believe I did anything special
> to configure that. Check your local readline documentation.
>
> As Adrian notes, there's also \e, which is good for entering
> or editing multi-line queries.
>
There's got to be something in your shell config which says "use emacs
keys" instead of "use vi keys".
--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
2025-02-12 20:03 ` Re: psql command line editing Ron Johnson <[email protected]>
@ 2025-02-12 20:29 ` Adrian Klaver <[email protected]>
2025-02-13 19:11 ` Re: psql command line editing Ron Johnson <[email protected]>
1 sibling, 1 reply; 14+ messages in thread
From: Adrian Klaver @ 2025-02-12 20:29 UTC (permalink / raw)
To: Ron Johnson <[email protected]>; pgsql-general
On 2/12/25 12:03, Ron Johnson wrote:
> On Wed, Feb 12, 2025 at 2:29 PM Tom Lane <[email protected]
> <mailto:[email protected]>> wrote:
> There's got to be something in your shell config which says "use emacs
> keys" instead of "use vi keys".
From man readline:
"By default, the line editing commands are similar to those of emacs. A
vi-style line editing interface is also available."
To change from the default would involve setting editing-mode in
/etc/inputrc or ~/.inputrc.
>
> --
> Death to <Redacted>, and butter sauce.
> Don't boil me, I'm still alive.
> <Redacted> lobster!
--
Adrian Klaver
[email protected]
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
2025-02-12 20:03 ` Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 20:29 ` Re: psql command line editing Adrian Klaver <[email protected]>
@ 2025-02-13 19:11 ` Ron Johnson <[email protected]>
2025-02-13 19:14 ` Re: psql command line editing Rob Sargent <[email protected]>
0 siblings, 1 reply; 14+ messages in thread
From: Ron Johnson @ 2025-02-13 19:11 UTC (permalink / raw)
To: pgsql-general
On Wed, Feb 12, 2025 at 3:29 PM Adrian Klaver <[email protected]>
wrote:
> On 2/12/25 12:03, Ron Johnson wrote:
> > On Wed, Feb 12, 2025 at 2:29 PM Tom Lane <[email protected]
> > <mailto:[email protected]>> wrote:
>
> > There's got to be something in your shell config which says "use emacs
> > keys" instead of "use vi keys".
>
> From man readline:
>
> "By default, the line editing commands are similar to those of emacs. A
> vi-style line editing interface is also available."
>
> To change from the default would involve setting editing-mode in
> /etc/inputrc or ~/.inputrc.
>
It appears that the RHEL default /etc/initrc file defines a bunch of escape
sequences "for linux console and RH/Debian xterm" cursor keys when in emacs
mode.
Our servers are RHEL, my ssh client emulates xterm, and is in the default
emacs mode. Thus, the cursor keys automagically work for me, and I just
learned that I've been in emacs mode this whole time!
--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
2025-02-12 20:03 ` Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 20:29 ` Re: psql command line editing Adrian Klaver <[email protected]>
2025-02-13 19:11 ` Re: psql command line editing Ron Johnson <[email protected]>
@ 2025-02-13 19:14 ` Rob Sargent <[email protected]>
0 siblings, 0 replies; 14+ messages in thread
From: Rob Sargent @ 2025-02-13 19:14 UTC (permalink / raw)
To: [email protected]
On 2/13/25 12:11, Ron Johnson wrote:
> It appears that the RHEL default /etc/initrc file defines a bunch of
> escape sequences "for linux console and RH/Debian xterm" cursor keys
> when in emacs mode.
>
> Our servers are RHEL, my ssh client emulates xterm, and is in the
> default emacs mode. Thus, the cursor keys automagically work for me,
> and I just learned that I've been in emacs mode this whole time!
>
> --
> Death to <Redacted>, and butter sauce.
> Don't boil me, I'm still alive.
> <Redacted> lobster!
We're an ancient -not to say insidious- cult.
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
2025-02-12 20:03 ` Re: psql command line editing Ron Johnson <[email protected]>
@ 2025-02-12 21:17 ` Rob Sargent <[email protected]>
2025-02-12 21:21 ` Re: psql command line editing Tom Lane <[email protected]>
1 sibling, 1 reply; 14+ messages in thread
From: Rob Sargent @ 2025-02-12 21:17 UTC (permalink / raw)
To: [email protected]
> There's got to be something in your shell config which says "use emacs
> keys" instead of "use vi keys".
>
> --
> Death to <Redacted>, and butter sauce.
> Don't boil me, I'm still alive.
> <Redacted> lobster!
Or something in yours setting vi?
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
2025-02-12 20:03 ` Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 21:17 ` Re: psql command line editing Rob Sargent <[email protected]>
@ 2025-02-12 21:21 ` Tom Lane <[email protected]>
2025-02-13 17:20 ` Re: psql command line editing Vincent Veyron <[email protected]>
0 siblings, 1 reply; 14+ messages in thread
From: Tom Lane @ 2025-02-12 21:21 UTC (permalink / raw)
To: Rob Sargent <[email protected]>; +Cc: [email protected]
Rob Sargent <[email protected]> writes:
>> There's got to be something in your shell config which says "use emacs
>> keys" instead of "use vi keys".
> Or something in yours setting vi?
I do have
export EDITOR=emacs
Possibly libreadline is reacting to that, but I've not checked
into it.
regards, tom lane
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
2025-02-12 20:03 ` Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 21:17 ` Re: psql command line editing Rob Sargent <[email protected]>
2025-02-12 21:21 ` Re: psql command line editing Tom Lane <[email protected]>
@ 2025-02-13 17:20 ` Vincent Veyron <[email protected]>
2025-02-13 17:29 ` Re: psql command line editing Adrian Klaver <[email protected]>
0 siblings, 1 reply; 14+ messages in thread
From: Vincent Veyron @ 2025-02-13 17:20 UTC (permalink / raw)
To: [email protected]
On Wed, 12 Feb 2025 16:21:21 -0500
Tom Lane <[email protected]> wrote:
> I do have
>
> export EDITOR=emacs
>
> Possibly libreadline is reacting to that, but I've not checked
> into it.
>
Emacs combinations work on my machine without it.
--
Bien à vous, Vincent Veyron
https://compta.libremen.com
Logiciel libre de comptabilité générale en partie double
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: psql command line editing
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Re: psql command line editing Tom Lane <[email protected]>
2025-02-12 20:03 ` Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 21:17 ` Re: psql command line editing Rob Sargent <[email protected]>
2025-02-12 21:21 ` Re: psql command line editing Tom Lane <[email protected]>
2025-02-13 17:20 ` Re: psql command line editing Vincent Veyron <[email protected]>
@ 2025-02-13 17:29 ` Adrian Klaver <[email protected]>
0 siblings, 0 replies; 14+ messages in thread
From: Adrian Klaver @ 2025-02-13 17:29 UTC (permalink / raw)
To: Vincent Veyron <[email protected]>; [email protected]
On 2/13/25 09:20, Vincent Veyron wrote:
> On Wed, 12 Feb 2025 16:21:21 -0500
> Tom Lane <[email protected]> wrote:
>
>
>> I do have
>>
>> export EDITOR=emacs
>>
>> Possibly libreadline is reacting to that, but I've not checked
>> into it.
>>
>
> Emacs combinations work on my machine without it.
See my answer here:
https://www.postgresql.org/message-id/4e1966c1-1f24-47e5-9c87-8cf466216b6b%40aklaver.com
for why.
--
Adrian Klaver
[email protected]
^ permalink raw reply [nested|flat] 14+ messages in thread
end of thread, other threads:[~2025-02-13 19:14 UTC | newest]
Thread overview: 14+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-02-12 18:55 Re: psql command line editing Ron Johnson <[email protected]>
2025-02-12 19:29 ` Tom Lane <[email protected]>
2025-02-12 19:44 ` Rich Shepard <[email protected]>
2025-02-12 19:50 ` Adrian Klaver <[email protected]>
2025-02-12 19:54 ` Rich Shepard <[email protected]>
2025-02-12 22:09 ` Ben Hancock <[email protected]>
2025-02-12 20:03 ` Ron Johnson <[email protected]>
2025-02-12 20:29 ` Adrian Klaver <[email protected]>
2025-02-13 19:11 ` Ron Johnson <[email protected]>
2025-02-13 19:14 ` Rob Sargent <[email protected]>
2025-02-12 21:17 ` Rob Sargent <[email protected]>
2025-02-12 21:21 ` Tom Lane <[email protected]>
2025-02-13 17:20 ` Vincent Veyron <[email protected]>
2025-02-13 17:29 ` Adrian Klaver <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox