I'm using iTerm2 w/ bash and I scroll up through the history buffer one line by typing Shift+Up. When I switch to my zsh shell, it just inputs 2A. How can I scroll up a single line in zsh w/ just my keyboard, preferably using Shift+Up?

2 Answers 2


I think it depends from the terminal emulator.

For example, with zsh, in konsole it works Shift+Up.
In xterm not, but it works Shift+PgUp.

It seems that with iTerm2 it should work by default :

  • to move one line up
  • to move one line down
  • In ZSH in Arch Linux inside Virtualbox inside Windows 8, it was Shift+PgUp
    – JPain
    Jan 23, 2016 at 22:30

The function you are looking for is provided by the up-history and up-line-or-history widgets (down-history and down-line-or-history for scrolling down).

By default up-line-or-history should be bound to Up but you can bind it to (almost) any other key sequence with bindkey. In terminals special keys (keys that do not generate a printable character) generate a sequence of keys that is then interpreted by the shell - or not, as your example of 2A for Shift+Up shows. These key sequences also may differ between terminal emulators. In order to get the correct key sequence for your terminal, open it, then press Ctrl+v followed by the key combination you want (Shift+Up). On my terminal (rxvt-unicode) I get ^[[a. You can then bind the sequence to the up-history widged:

bindkey <in-string> up-history

Just replace <in-string> with the found sequence. In my case

bindkey '^[[a' up-history

Note 1: You most likely need to put the sequence in quotes as it probably will contain characters that will be interpreted by zsh otherwise.

Note 2: Some key combinations may generate identical key sequences. For example, letters combined with Ctrl+Shift usually do not differ from the same letters combined with just Ctrl. Both, Ctrl+Shift+a and Ctrl+a usually produce ^A. In some terminal emulators Ctrl+Shift combinations are even used for shortcuts of the terminal itself and are not available in the shell.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .