Prezto: Up arrow isn't working for history-substring-search after submodule update

Created on 17 Dec 2013  ·  42Comments  ·  Source: sorin-ionescu/prezto

Bug Upstream

All 42 comments

Restore the submodule to the Prezto version.

It is the Prezto version, 1e7680405239a835aa403a7457cad23750f98e72. This is with a fresh checkout of Prezto (I blew away all my modifications earlier to ensure I wasn't crazy).

It works on my end. Perhaps there is something wrong with your Terminal.

It looks like I accidentally upgraded to zsh 5.0.3 yesterday, perhaps something changed?

I don't know. I'm running 5.0.2. Find out.

I can confirm this issue running 5.0.3 as well. On 5.0.2 it worked.

Just switched back to 5.0.2 and problems are gone. I also had troubles using tab completions on git popping up __git_aliased_command:5: bad pattern: !gitk|gitk. On 5.0.2 everything works fine - will stay there for now.

I can confirm that it occurs on 5.0.3. Right now, I'm categorising the bug as upstream.

Does history-substring-search work without Prezto?

For those of you who use Homebrew on Mac, you can use brew pin zsh to prevent brew upgrade from upgrading Zsh to v5.0.3.

I'm having the same issue.

Using Homebrew? brew switch zsh 5.0.2 reverts the 5.0.3 upgrade. Then pin as mentioned above.

Not related to prezto, but my git completion seems to break with 5.0.3 as well.

Homebrew users, if @leoj3n's suggestion didn't work for you:

$ brew uninstall zsh
$ cd $(brew --prefix)
$ git checkout 52fe004 Library/Formula/zsh.rb
$ brew install zsh
$ brew pin zsh

thanks @leoj3n !

It seems to have been fixed in Zsh v5.0.4. Close this issue when confirmed.

On my end,

zsh 5.0.4 (x86_64-apple-darwin12.5.0)

seems to have the same issue with completions history substring search.

I upgraded via Homebrew:

brew unpin zsh
brew switch zsh 5.0.3
brew update
brew upgrade
==> Upgrading 1 outdated package, with result:
zsh 5.0.4
==> Upgrading zsh
==> Downloading http://fossies.org/linux/misc/zsh-5.0.4.tar.bz2
...

Restart iTerm 2, problem persists.

@leoj3n We're not talking about completions, just arrows in history substring search.

@sorin-ionescu Sorry, that's what I meant. Completions work fine with 5.0.4 (updated my previous comment).

It works on my end.

Can't confirm it either on zsh 5.0.4 (x86_64-apple-darwin13.0.0). Issue persists here, too.

@arppl Completions work for me. My only issue is still substring history search.

@sorin-ionescu Do you have any troubleshooting tips we should try?

~ ❯❯❯ brew info zsh
zsh: stable 5.0.4
http://www.zsh.org/
/usr/local/Cellar/zsh/5.0.2 (1053 files, 8.7M)
  Built from source
/usr/local/Cellar/zsh/5.0.3 (1063 files, 8.9M)
  Built from source
/usr/local/Cellar/zsh/5.0.4 (1063 files, 8.9M) *
  Built from source
From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/zsh.rb
==> Dependencies
Required: gdbm ✔, pcre ✔
==> Options
--enable-etcdir
    Enable the reading of Zsh rc files in /etc
==> Caveats
To use this build of Zsh as your login shell, add it to /etc/shells.

Add the following to your zshrc to access the online help:
  unalias run-help
  autoload run-help
  HELPDIR=/usr/local/share/zsh/helpfiles

I've always had these caveats "installed" and I have not used the --enable-etcdir flag. Any other info needed?

@sorin-ionescu Could this have something to do with the way we're installing Zsh? I assume you build from source. Do you do anything special when installing Zsh?

I brew install zsh --enable-etcdir. I don't enable run-help since it's mostly useless. Make sure you are in the right Zsh with print $ZSH_VERSION. You're right, it doesn't work in 5.0.4. I have got confused with the default system Zsh. However, Ctrl + P and Ctrl + N do work.

In Zsh 4.3.11, which is the Zsh version that comes with the system, here's what I have.

$ bindkey -L | grep history-substring-search
bindkey "^N" history-substring-search-down
bindkey "^P" history-substring-search-up
bindkey "^[OA" history-substring-search-up
bindkey "^[OB" history-substring-search-down

I think that there is something wrong with zsh/terminfo in v5.0.3+. Prezto essentially does the following in the editor module.

zmodload zsh/terminfo
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down

If you paste the following in the terminal or add it to zshrc, the arrows work again.

bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down

I'm not sure what to do about this. I would rather not manually add escape codes and rather depend on terminfo since said escape codes are different on different platforms/terminals.

I guess it should be reported upstream, i can try to ping somebody in their IRC

No, report it on the mailing list.

On Jan 7, 2014, at 13:31, ibeex [email protected] wrote:

I guess it should be reported upstream, i can try to ping somebody in their IRC


Reply to this email directly or view it on GitHub.

Response from miling list

The correct values largely depend on the value of $TERM. For example,
with $TERM := screen, the correct value is "^[OA".

What might be confusing you, is the fact that the values from $terminfo
are _only_ valid in "keyboard-transmit-mode". That's the mode you enter,
by issuing "smkx" and you leave by "rmkx" (see terminfo(5)).

Zsh's line editor (zle), does not do this by default, but it can by made
to do that, when it is active. One caveat to note is, that not all
terminals _have_ an explicit "smkx" mode (they just default to being in
"keyboard-transmit-mode" all the time), so you need to check for the
ability of the terminal before trying to use it:

zle-line-init () {
    (( ${+terminfo[smkx]} )) && echoti smkx
}
zle-line-finish () {
    (( ${+terminfo[rmkx]} )) && echoti rmkx
}

here is report on mailing list http://www.zsh.org/mla/users/2014/msg00028.html

@ibeex I used to have that; see #263 and #314.

Actually, I still have those commands in the editor module.

@sorin-ionescu somebody suggested me to look at debian zshrc i can see only slight difference from editor module, can you take look?

emulate -L zsh?

as temporary solution I remaped Up and Down keys in iTerm2 to reported values ^[OA and ^[OB

Issue persists in zsh 5.0.5, FYI

@ibeex Does the debian zshrc work for you?

I have found the problem. It's an upstream bug, as I have suspected, but I have also found the way to get around it.

I am defining three functions with the same function body to not repeat myself. Even though I have verified that the functions have been defined properly, they exist, my zle-line-init and zle-line-finish are not being called. Something must have changed in recent Zsh versions that affects this.

When I split that code into three distinct function definitions, it works.

@ibeex I would appreciate if you inform the mailing about this issue. Thank you.

Doesn't look like it's fixed in 5.0.5 :(

I'm also having problems on 5.0.5, debian, latest version of zpretzo.

Not sure if it's relevant, but there still seems to be a difference between $terminfo and the actual keycodes:

~/.z/.zprezto git:master ❯❯❯ zsh --version
zsh 5.0.5 (x86_64-pc-linux-gnu)
~/.z/.zprezto git:master ❯❯❯ echo "$terminfo[kcuu1]"
A
~/.z/.zprezto git:master ❯❯❯ echo "$terminfo[kcud1]"
B
~/.z/.zprezto git:master ❯❯❯ echo '^[[A'
^[[A
~/.z/.zprezto git:master ❯❯❯ echo '^[[B'
^[[B

Manually mapping the keys in .zshrc fixes the problem for me.

There is nothing I can do about broken terminfo databases. You can install your own terminfo databases in your home directory with the keys fixed. Or, you can force your terminal emulator to send different escape codes.

@sorin-ionescu thanks, I'll look into that. Just figured the info might be useful for somebody else trying to debug this.

I had this problem too, and like @BRMatt, remapping it manually through the .zshrc worked. The listed key (bindkey -L) was '\eOA', and linking it to '\e[A' or '^[[A' worked (bindkey -s).

Just to contribute: On zsh 5.0.2, Ubuntu 14.04, I have this issue with Xfce-terminal. In gnome-terminal, Konsole, rxvt and terminator everything works fine.

Was this page helpful?
0 / 5 - 0 ratings