up/down in pdksh-history with "set -o vi"

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

up/down in pdksh-history with "set -o vi"

Stefan Olsson
Hello,

I suspect my problem is not entirely OpenBSD-related but more to do with
pdksh and keybindings.

I usually do "set -o vi" in my .profile. In bash on OS/X it then works to
go up and down in history with both j+k or up+down-keys. If I ssh to a
OpenBSD host from my Mac, I can NOT use up+down in the shell (ksh), but it
works fine in less or vi. It even works fine with up+down keys in bash on
OpenBSD - so what do I need to do in ksh to make up+down-keys work (apart
from doing "set -o emacs")??

sturban@LassoLouise:~ $ bind | egrep "prefix-2|up-history|down-history"
^N = down-history
^P = up-history
^X = prefix-2
^[O = prefix-2
^[[ = prefix-2
^XA = up-history
^XB = down-history

-----

TERM=xterm-256color

And yes, I have read this message already:
http://www.mail-archive.com/misc@.../msg81796.html

Kind Regards,

Reply | Threaded
Open this post in threaded view
|

Re: up/down in pdksh-history with "set -o vi"

Anthony J. Bentley-3
Stefan Olsson writes:

> Hello,
>
> I suspect my problem is not entirely OpenBSD-related but more to do with
> pdksh and keybindings.
>
> I usually do "set -o vi" in my .profile. In bash on OS/X it then works to
> go up and down in history with both j+k or up+down-keys. If I ssh to a
> OpenBSD host from my Mac, I can NOT use up+down in the shell (ksh), but it
> works fine in less or vi. It even works fine with up+down keys in bash on
> OpenBSD - so what do I need to do in ksh to make up+down-keys work (apart
> from doing "set -o emacs")??
>
> sturban@LassoLouise:~ $ bind | egrep "prefix-2|up-history|down-history"
> ^N = down-history
> ^P = up-history
> ^X = prefix-2
> ^[O = prefix-2
> ^[[ = prefix-2
> ^XA = up-history
> ^XB = down-history
>
> -----
>
> TERM=xterm-256color
>
> And yes, I have read this message already:
> http://www.mail-archive.com/misc@.../msg81796.html

I guess it's a bug. See:
http://marc.info/?l=openbsd-misc&m=135757054604300&w=2

Reply | Threaded
Open this post in threaded view
|

Re: up/down in pdksh-history with "set -o vi"

Alexander Polakov
In reply to this post by Stefan Olsson
* Stefan Olsson <[hidden email]> [130412 03:50]:

> Hello,
>
> I suspect my problem is not entirely OpenBSD-related but more to do with
> pdksh and keybindings.
>
> I usually do "set -o vi" in my .profile. In bash on OS/X it then works to
> go up and down in history with both j+k or up+down-keys. If I ssh to a
> OpenBSD host from my Mac, I can NOT use up+down in the shell (ksh), but it
> works fine in less or vi. It even works fine with up+down keys in bash on
> OpenBSD - so what do I need to do in ksh to make up+down-keys work (apart
> from doing "set -o emacs")??

You can recompile ksh with my unportable hack if you really want to:

http://plhk.ru/trash/ksh/0008-ksh-vi-arrow-keys-support.patch

--
Alexander Polakov | plhk.ru

Reply | Threaded
Open this post in threaded view
|

Re: up/down in pdksh-history with "set -o vi"

Ted Unangst-6
In reply to this post by Stefan Olsson
On Fri, Apr 12, 2013 at 00:05, Stefan Olsson wrote:

> I usually do "set -o vi" in my .profile. In bash on OS/X it then works to
> go up and down in history with both j+k or up+down-keys. If I ssh to a
> OpenBSD host from my Mac, I can NOT use up+down in the shell (ksh), but it
> works fine in less or vi. It even works fine with up+down keys in bash on
> OpenBSD - so what do I need to do in ksh to make up+down-keys work (apart
> from doing "set -o emacs")??

You fix the code.

I was going to say maybe we just need some default keybindings for vi
mode, but a glance at the code reveals emacs and vi modes are
implemented totally separately. hurray! I suspect somewhere in
ksh/vi.c is a switch statement you could add the magic cases to for
arrow keys.

On the other hand, strictly speaking, vi doesn't support arrow keys.
vim in compatible mode or the stock vi on hpux (shudder) will just dump
control characters in your file for example. If you're going to be
hard core and use vi for command line editing, I'd say you should go
all in and only use hjkl too. :)

Reply | Threaded
Open this post in threaded view
|

Re: up/down in pdksh-history with "set -o vi"

Christian Weisgerber
Ted Unangst <[hidden email]> wrote:

> On the other hand, strictly speaking, vi doesn't support arrow keys.
> vim in compatible mode or the stock vi on hpux (shudder) will just dump
> control characters in your file for example.

Traditional vi does support arrow keys in command mode, just not
in insert mode.

(If you look at the termcap entries for some old terminals, you'll
find that many used ^H for both cursor left and erase.  The only
way to support both is to separate cursor movements and text entry
into different modes.)

--
Christian "naddy" Weisgerber                          [hidden email]