iTerm 2: How to set keyboard shortcuts to jump to beginning/end of line?

后端 未结 14 1897
难免孤独
难免孤独 2020-12-02 03:09

I can see that Ctrl+left/right jumps to the beginning/end of line. How to change this to Cmd+left/right arrow

14条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 03:49

    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.

提交回复
热议问题