Skip to content

Instantly share code, notes, and snippets.

@waltz
Created Jan 27, 2014
Embed
What would you like to do?
ZSH, iTerm2 Alt-Arrow (Left/Right) Key remap
# Remap alt-left and alt-right to forward/backward word skips.
# via @waltz, https://gist.github.com/waltz/8658549
bindkey "^[^[[D" backward-word
bindkey "^[^[[C" forward-word

Fix word jumping in ZSH and iTerm2

I've been a ZSH user for about a year now and I've been enjoying it a bunch. I'm also an emacs user and I've learned to love being able to use Emacs-style word jumping commands in apps that use GNU Readline.

@daguar was going on about how great iTerm2 was recently and I figured I should give it a shot. A few minutes later I was getting these inexplicable [C and [D messages when I went to bop around my command line like I'm used to.

A few websites give recommendations on how to work around this or what you're doing wrong, but none of them had an updated fix. Here 'ya go. Put the following code at the bottom of your .zshrc and enjoy the bliss of Emacs keybindings everywhere you're used to.

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