I'll try to describe an annoyance with my ksh setup. Web and man page
searching has not provided a solution. I'm relatively new to both ksh and
openbsd. I'm on version 5.9 release.
Problem happens when I navigate command history with ctrl-r, then use left or
right arrow. Hitting left arrow writes "[D", right inserts "[C". I'm hitting
the arrow keys so I can edit my prior command. It's a habit I'm used to that
works in bash.
For example to reproduce, let's say I ran "ls -l" but I wanted to run "ls
-la"...
run the first command, "ls -l".
type "ctrl-r ls". This works as expected, and my cursor is now in the middle
of "ls -l".
type right arrow. This is where the problem is. The command I'm editing
becomes "ls[C -l".
>From this point, arrow keys work as expected. I can use left or right to
>navigate and edit the command.
If, instead of arrows, I use ctrl-b or ctrl-f, these work fine. No artifacts
like "[C" or "[D".
If I use bash instead of ksh, this problem does not occur.
I found suggestions to add aliases like the following to ~/.ksh, which I've
attempted but seem to have no effect:
alias __C=`echo "\006"` # right arrow = ^f = forward a character
alias __D=`echo "\002"` # left arrow = ^b = back a character
I understand from `man ksh` that these key bindings are defaults:
bind '^[[C'=forward-char
bind '^[[D'=backward-char
My assumption is that when in ctrl-r mode, the '^[' is interpreted as part of
the ctrl-r search (which doesn't match), then the '[C' or '[D' is interpreted
as the next key (which is inserted). Can this behavior be changed?
Any help appreciated. Thanks!
-Dave