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
merged 5 commits into from Mar 13, 2014

Conversation

@F30
Copy link
Contributor

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.

@crcastle
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!

@assaflavi
Copy link

assaflavi commented Jan 12, 2013

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

@vanhalt
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
wget https://raw.github.com/F30/oh-my-zsh/174c9177aa34b4c05bb5a1c6f637e6fa479a8e10/lib/key-bindings.zsh

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

Thanks to @F30!

@carlosagp
Copy link

carlosagp commented Jul 6, 2013

+1 This is a good patch. Please merge!

@Taluu
Copy link

Taluu commented Jan 22, 2014

This did the trick for me. :)

@thisch
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
@thuandt
Copy link
Contributor

thuandt commented Mar 13, 2014

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

@mcornella
Copy link
Member

mcornella commented Mar 13, 2014

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)

@pierrre
Copy link

pierrre commented Mar 14, 2014

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

@mgol

This comment has been minimized.

Copy link

mgol commented on ff0cafa Mar 18, 2014

This introduced issue #2628.

This comment has been minimized.

Copy link
Contributor

eddiemonge replied Apr 21, 2014

and #2654

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

Successfully merging this pull request may close these issues.

None yet

You can’t perform that action at this time.