Fix key settings (Home/End/Insert/Delete) in .zshrc when running Zsh in Terminator Terminal Emulator

后端 未结 4 492
独厮守ぢ
独厮守ぢ 2020-12-23 02:31

I\'m running Ubuntu 11.04. I installed the Terminator Terminal Emulator 0.95, and Zsh, version 4.3.15.
I have (commonly known) problems with my keys inside the Zsh. At

相关标签:
4条回答
  • 2020-12-23 02:32

    Thanks to @lolesque, but the solution doesn't work with me. After using zkbd to check my key binding, I came out the below solution. BTW, my $TERM is xterm.

    bindkey  "^[[1~"   beginning-of-line
    bindkey  "^[[4~"   end-of-line
    

    Hope it helps.

    0 讨论(0)
  • 2020-12-23 02:35

    Setting the TERM variable in .zshrc caused this for me.

    0 讨论(0)
  • 2020-12-23 02:53

    To know the code of a key, execute cat, press enter, press the key, then Ctrl+C.

    For me, Home sends ^[[H and End ^[[F, so i can put i my .zshrc in my home dir

    bindkey  "^[[H"   beginning-of-line
    bindkey  "^[[F"   end-of-line
    bindkey  "^[[3~"  delete-char
    

    These codes could change with the terminal emulator you use.

    autoload zkbd ; zkbd will create a file with an array of keycodes to use, like bindkey "${key[Home]}" beginning-of-line, and you can source a different file depending on the terminal.

    0 讨论(0)
  • 2020-12-23 02:58

    For me on WSL2 (Windows 10) this was it

    bindkey "^[OH" beginning-of-line
    bindkey "^[OF" end-of-line
    

    The cat trick did not work for me as it printed ^[[H as in the accepted answer but I was able to find out the ^[OH sequence by typing Ctrl+v Home in the new Window Terminal running zsh.

    0 讨论(0)
提交回复
热议问题