I can see that Ctrl+left/right jumps to the beginning/end of line. How to change this to Cmd+left/right arrow
For quick reference of anyone who wants to go to the end of line or start of line in iTerm2, the above link http://hackaddict.blogspot.com/2007/07/skip-to-next-or-previous-word-in-iterm.html notes that in iTerm2:
The old fashion emacs bindings can still work in iterm2 and os x terminal:
Preferences -> Profiles -> Keys (sub tab in profiles)
Left/Right option <kbd>⌥</kbd> key acts as +Esc
(similar in os x terminal)This should enable alt-f and alt-b for moving words by words. (Still ctrl-a and ctrl-e always work as usual)
If set as meta
those old bindings will work while some iterm2 bindings unavailable.
bind -p
will show a list of bound escaped keys in your shell, that might help giving you more ideas / search terms.
In iTerm 3.0.12 you can switch to Natural Text Editing
preset:
iTerm → Preferences → Profiles → Keys
Warning As it is a preset, it can override the keys you have binded before. So it's better to save your current key bindings before applying a preset.
I used Travis answer and I created a dynamic profile you can import based on its instructions.
GabLeRoux/iterm2-macos-dynamic-profile
Instructions are in the readme and it's a lot faster to import this than it is to add them all manually. I made this an answer as per @gooli's request because this was hidden in a comment. Hope you enjoy this
Just to help out anyone that is having the same issue but specifically using Zsh shell with iTerm 2. It turns out that Zsh doesn't read /etc/inputrc properly, and so fails to understand any key bindings you set up through the preferences!
To fix this, you need to add some key bindings to your .zshrc
file, such as:
# key bindings
bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
Note the backslashes in the example above before the "e", the linked article does not show them, so add them into your .zshrc
file when adding bindings.