psql command line editor

Started by Bob Gobeilleover 16 years ago11 messagesgeneral
Jump to latest
#1Bob Gobeille
bob.gobeille@hp.com

I use PSQL to set my editor to vi. This works as expected in psql, \e
brings up vi and I edit away.

Is there any way to set my psql command line editor to also use vi
(just like I do with "set -o vi" in bash)?
I can't find this in the docs.

Thanks,
Bob Gobeille
bobg@fossology.org

#2Bob Gobeille
bob.gobeille@hp.com
In reply to: Bob Gobeille (#1)
Re: psql command line editor

On Aug 17, 2009, at 11:30 AM, Gobeille, Robert wrote:

I use PSQL to set my editor to vi. This works as expected in psql, \e
brings up vi and I edit away.

Is there any way to set my psql command line editor to also use vi
(just like I do with "set -o vi" in bash)?
I can't find this in the docs.

That should have been PSQL_EDITOR.

bob

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bob Gobeille (#1)
Re: psql command line editor

Bob Gobeille wrote:

I use PSQL to set my editor to vi. This works as expected in psql,
\e brings up vi and I edit away.

Is there any way to set my psql command line editor to also use vi
(just like I do with "set -o vi" in bash)?
I can't find this in the docs.

I have in my .inputrc this line:

set editing-move vi

and it works like a charm.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#4Bob Gobeille
bob.gobeille@hp.com
In reply to: Alvaro Herrera (#3)
Re: psql command line editor

On Aug 17, 2009, at 12:46 PM, Alvaro Herrera wrote:

Bob Gobeille wrote:

I use PSQL to set my editor to vi. This works as expected in psql,
\e brings up vi and I edit away.

Is there any way to set my psql command line editor to also use vi
(just like I do with "set -o vi" in bash)?
I can't find this in the docs.

I have in my .inputrc this line:

set editing-move vi

and it works like a charm.

I tried this and can't get it to work.
1) I tried putting that in my .bashrc script and sourcing the file
(and also logging in again)
2) I did the set on the command line and then started psql

No luck.

I'm testing by:

starting psql
use the up arrow to bring up a previous command from the command buffer
try to reposition the cursor around the command with '0' or '$' or 'w'
or 'h'
No luck.

I don't find any mention of 'editing-move' in a search of postgresql.org
Googling editing-move turns up nothing (as far as I looked through
results).

This is 8.3 on a debian lenny system. What am I missing?

Thanks!
Bob

#5Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bob Gobeille (#4)
Re: psql command line editor

Bob Gobeille wrote:

I have in my .inputrc this line:

set editing-move vi

and it works like a charm.

I tried this and can't get it to work.
1) I tried putting that in my .bashrc script and sourcing the file
(and also logging in again)
2) I did the set on the command line and then started psql

No luck.

Try reading my first sentence.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#6Bob Gobeille
bob.gobeille@hp.com
In reply to: Alvaro Herrera (#5)
Re: psql command line editor

On Aug 17, 2009, at 1:18 PM, Alvaro Herrera wrote:

Bob Gobeille wrote:

I have in my .inputrc this line:

set editing-move vi

and it works like a charm.

I tried this and can't get it to work.
1) I tried putting that in my .bashrc script and sourcing the file
(and also logging in again)
2) I did the set on the command line and then started psql

No luck.

Try reading my first sentence.

I left that out. Creating a ~/.inputrc with that line and relogging
in was the first thing I tried.

Bob

#7Steve Atkins
steve@blighty.com
In reply to: Bob Gobeille (#4)
Re: psql command line editor

On Aug 17, 2009, at 12:15 PM, Bob Gobeille wrote:

On Aug 17, 2009, at 12:46 PM, Alvaro Herrera wrote:

Bob Gobeille wrote:

I use PSQL to set my editor to vi. This works as expected in psql,
\e brings up vi and I edit away.

Is there any way to set my psql command line editor to also use vi
(just like I do with "set -o vi" in bash)?
I can't find this in the docs.

I have in my .inputrc this line:

set editing-move vi

and it works like a charm.

I tried this and can't get it to work.
1) I tried putting that in my .bashrc script and sourcing the file
(and also logging in again)
2) I did the set on the command line and then started psql

It's a readline setting, not an environment variable. Try putting it
in ~/.inputrc.

Though it looks like you're on a Mac, and that's likely to be using
editline
rather than readline, in which case putting "bind -v" in ~/.editrc
would be
what you need. That'll start you in input mode, so 'esc' should switch
you
to navigation mode.

Cheers,
Steve

#8kbarnard@kevinbarnard.net
kbarnard@kevinbarnard.net
In reply to: Alvaro Herrera (#3)
Re: psql command line editor

On Aug 17, 2009, at 1:46 PM, Alvaro Herrera wrote:

Bob Gobeille wrote:

I use PSQL to set my editor to vi. This works as expected in psql,
\e brings up vi and I edit away.

Is there any way to set my psql command line editor to also use vi
(just like I do with "set -o vi" in bash)?
I can't find this in the docs.

I have in my .inputrc this line:

set editing-move vi

and it works like a charm.

Shouldn't that be editing-mode not move

#9Bob Gobeille
bob.gobeille@hp.com
In reply to: Steve Atkins (#7)
Re: psql command line editor

On Aug 17, 2009, at 1:27 PM, Steve Atkins wrote:

On Aug 17, 2009, at 12:15 PM, Bob Gobeille wrote:

On Aug 17, 2009, at 12:46 PM, Alvaro Herrera wrote:

Bob Gobeille wrote:

I use PSQL to set my editor to vi. This works as expected in psql,
\e brings up vi and I edit away.

Is there any way to set my psql command line editor to also use vi
(just like I do with "set -o vi" in bash)?
I can't find this in the docs.

I have in my .inputrc this line:

set editing-move vi

and it works like a charm.

I tried this and can't get it to work.
1) I tried putting that in my .bashrc script and sourcing the file
(and also logging in again)
2) I did the set on the command line and then started psql

It's a readline setting, not an environment variable. Try putting it
in ~/.inputrc.

Though it looks like you're on a Mac, and that's likely to be using
editline
rather than readline, in which case putting "bind -v" in ~/.editrc
would be
what you need. That'll start you in input mode, so 'esc' should switch
you
to navigation mode.

My workstation is a mac laptop, so that's where my email client is.
I'm running psql on a debian lenny server.
I have the set command in my ~/.inputrc. I even logged out and back
in. But in psql I type in a command, hit escape then 0 to go to the
beginning of the line - no go. I do see things like ^r doing a
reverse search but basic cursor movement commands like 'w', '0', '$',
etc do not work.

Bob

#10Bob Gobeille
bob.gobeille@hp.com
In reply to: kbarnard@kevinbarnard.net (#8)
Re: psql command line editor

On Aug 17, 2009, at 1:38 PM, kbarnard@kevinbarnard.net wrote:

On Aug 17, 2009, at 1:46 PM, Alvaro Herrera wrote:

Bob Gobeille wrote:

I use PSQL to set my editor to vi. This works as expected in psql,
\e brings up vi and I edit away.

Is there any way to set my psql command line editor to also use vi
(just like I do with "set -o vi" in bash)?
I can't find this in the docs.

I have in my .inputrc this line:

set editing-move vi

and it works like a charm.

Shouldn't that be editing-mode not move

Whoo hoo. Thank you . Now it works like a charm. :-)

Bob

#11Jasen Betts
jasen@xnet.co.nz
In reply to: Bob Gobeille (#1)
Re: psql command line editor

On 2009-08-17, Bob Gobeille <bob.gobeille@hp.com> wrote:

I use PSQL to set my editor to vi. This works as expected in psql, \e
brings up vi and I edit away.

Is there any way to set my psql command line editor to also use vi
(just like I do with "set -o vi" in bash)?
I can't find this in the docs.

psql command-line eritor is "readline" and being a GNU product
it defaults to emacs mode :)

do "man 3 realine" for more info
search for INPUTRC - less uses vi bindings :)