Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use terminfo key codes instead of hardcoded ones for key bindings #1355

merged 5 commits into from Mar 13, 2014

Use terminfo key codes instead of hardcoded ones for key bindings #1355

merged 5 commits into from Mar 13, 2014


Copy link

@F30 F30 commented Oct 14, 2012

Hardcoded key escape sequences (such as [[A for arrow-up) serve their purpose in most cases, but not in any terminal configuration. It's a better practice to query the right codes dynamically from $terminfo instead.

I expect this to become a real-world problem as soon as recent Debian and Ubuntu versions become used more widely: Those ship with a /etc/zsh/zshrc which enables "application mode", in which oh-my-zsh's key bindings partially don't work. I've written down more about that problem on my blog.

My commits migrate the key bindings to terminfo wherever possible. Please note that in order to use $terminfo, my code hast to activate the "application mode" as well and might therefore break custom hardcoded key bindings. I based my work on the documentation efforts by @kylewest from pull request #889.

Copy link

crcastle commented Dec 7, 2012

I just did an upgrade of oh-my-zsh, and the history-substring-search plugin broke. I fixed it by adding the following two lines to my personal zshrc (non oh-my-zsh) file.

bindkey '\eOA' history-substring-search-up
bindkey '\eOB' history-substring-search-down

I figured this out by doing Ctrl-v <up-arrow> before and after the oh-my-zsh upgrade. Before it returned ^[[A. Now it returns ^[OA.

I think this pull request is the better way to deal with this. Please merge it in!

Copy link

Thanks, F30, for this fix. I adopted your changes manually, but I hope they get merged to master soon.

Copy link

vanhalt commented Apr 18, 2013

Tested in:

lsb_release -a
Description:    Ubuntu 12.10
Release:        12.10

zsh --version
zsh 5.0.0 (x86_64-unknown-linux-gnu)

Applied manually:

mv key-bindings.zsh key-bindings_original.zsh

Really dirty but did the job, please merge this :)

Thanks to @F30!

Copy link

+1 This is a good patch. Please merge!

Copy link

Taluu commented Jan 22, 2014

This did the trick for me. :)

Copy link

thisch commented Jan 22, 2014

Please merge

robbyrussell added a commit that referenced this pull request Mar 13, 2014
Use terminfo key codes instead of hardcoded ones for key bindings
@robbyrussell robbyrussell merged commit 7adf66f into ohmyzsh:master Mar 13, 2014
Copy link

thuandt commented Mar 13, 2014

After update oh-my-zsh with this patch, plugin history-substring-search don't work

Copy link

Hi @thuandt, I recommend you open a new issue to have a better chance of being seen. Within the new issue, make sure to add your system version (lsb_release -a) and zsh version (zsh --version)

Copy link

pierrre commented Mar 14, 2014

+1 history search with up/down arrow key is broken...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet