a8uxma
Last Updated: February 25, 2016
·
7.062K
· teamon
9fae8c5d475fe322a3a74e53d56ee2a0

zsh + iTerm2 OSX shortcuts

We all love OSX built-in shortcuts
⌥ + ← or → - move one word backward/forward
⌘ + ← or → - move to beginning/end of line

In zsh you can use ctrl + a/e to move to beginning/end of line and esc + W/B to move one word backward/forward, but that's not very handy.

Here is a solution to map ⌥ + ← / → and ⌘ + ← / → to work in iTerm2 as expected

Put this in your .zshrc

bindkey "[D" backward-word
bindkey "[C" forward-word
bindkey "^[a" beginning-of-line
bindkey "^[e" end-of-line

Then open iTerm2 preferences and set

iterm2 preferences

You have to choose "Send escape sequence" action and put there only "a" or "e".

PROFIT!

Say Thanks
Respond

1 Response
Add your response

5091
D1a7e0fbfb2c1d9a8b10fd03648da78f

thank you very much for this. The goto beginning of line and end of line works just perfect with this however to move from words I have to put like this:

bindkey "\e\e[D" backward-word
bindkey "\e\e[C" forward-word

over 1 year ago ·
Filed Under