Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: up-arrow no longer works right

On 2009-03-20 at 02:03 -0400, TjL wrote:
> On Thu, Mar 19, 2009 at 10:48 PM, Phil Pennock
> <zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:
> > Perhaps the cursor keys have been put into application mode and your
> > terminal type isn't supporting them in that mode?
> I don't know what that means :-/

Any terminal emulator with a heritage that stretches back to emulating
VT100 terminals will implement a certain set of features, with
"standard" escape sequences for them.  This includes xterm and all the

One of these features is the ability to have the numeric keypad keys
send different characters to the normal digits, etc.  That's
"application mode".  The cursor keys can be put into a mode where they
send escape sequences which are similar to the application mode escape
sequences.  That seems to be more common.  I don't know enough about
such things to know why any application bothers to do this.

Normally, any program which changes the terminal mode will change it
back against afterwards, but if the program did not shut down cleanly,
or didn't get a chance to, then this won't happen.

So, if you want the up-key to always invoke a particular widgit, then
you need to bind *two* different escape sequences: both the normal \e[A
and also \eOA (where the escape sequence ESC is in more modern
environments written \e but in older setups is written ^[ instead).

> > If you run "bindkey", you'll see two batches for the two sets of cursor
> > keys; for me:
> > "^[OA" up-line-or-history
> > "^[OB" down-line-or-history
> > "^[OC" forward-char
> > "^[OD" backward-char
> > [...]
> > "^[[A" up-line-or-history
> > "^[[B" down-line-or-history
> > "^[[C" forward-char
> > "^[[D" backward-char
> >
> > If those two sets ^[O<foo> and ^[[<foo> differ then this might explain
> > it. ÂSo, (1) bind both sets the same and (2) see if "stty sane" helps.

> > And: Âprint -n '\e[?1l'
> that fixes it

So, bind ^[OA as well as ^[[A and the keys will still work even in
application mode.

Messages sorted by: Reverse Date, Date, Thread, Author