Skip to content

Instantly share code, notes, and snippets.

@waltz
Created January 27, 2014 22:22
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save waltz/8658549 to your computer and use it in GitHub Desktop.
Save waltz/8658549 to your computer and use it in GitHub Desktop.
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