使用 zsh 后HOME/END 键以及小键盘失效

#1 问题描述

zsh是一款超赞的shell工具,但是配置复杂,有个闲着没事的程序员,弄了一个开源项目 robbyrussell/oh-my-zsh 截止目前,58.8k+ star就知道有多火了。比如 Spring boot在github才 15.7K+ spring framework 也16.1k+,最近火到炸天的tensorflow 69.4k

同样很优秀的有 fisherman/fisherman

但是近期发现问题, 设置了 xshell 远程连接时, host将zsh设置成默认shell时, HOME/END 以及小键盘区诸键无效. 敲击没有任何反应.

#2 问题解决

##2.1 设置 xshell 连接终端的类型

第一种方法也是最简单的办法是,修改xshell连接此host的终端类型,改成linux

使用 zsh 后HOME/END 键以及小键盘失效_第1张图片

但是注意,改用 Linux 可能会导致shell的颜色比较奇怪.

##2.2 重新映射键值

在 ~/.zshrc 中将 HOME/END 等键值重新 MAP.

# key bindings
bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
bindkey "\e[5~" beginning-of-history
bindkey "\e[6~" end-of-history

# for rxvt
bindkey "\e[8~" end-of-line
bindkey "\e[7~" beginning-of-line
# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
bindkey "\eOH" beginning-of-line
bindkey "\eOF" end-of-line
# for freebsd console
bindkey "\e[H" beginning-of-line
bindkey "\e[F" end-of-line
# completion in the middle of a line
bindkey '^i' expand-or-complete-prefix

# Fix numeric keypad  
# 0 . Enter  
bindkey -s "^[Op" "0"
bindkey -s "^[On" "."
bindkey -s "^[OM" "^M"
# 1 2 3  
bindkey -s "^[Oq" "1"
bindkey -s "^[Or" "2"
bindkey -s "^[Os" "3"
# 4 5 6  
bindkey -s "^[Ot" "4"
bindkey -s "^[Ou" "5"
bindkey -s "^[Ov" "6"
# 7 8 9  
bindkey -s "^[Ow" "7"
bindkey -s "^[Ox" "8"
bindkey -s "^[Oy" "9"
# + - * /  
bindkey -s "^[Ol" "+"
bindkey -s "^[Om" "-"
bindkey -s "^[Oj" "*"
bindkey -s "^[Oo" "/"

#3 参考资料

Home and End keys not working on CentOS

Problem with home, end and del keys under zsh

ins-end-delete-keys-are-mischevious-297024

你可能感兴趣的:(使用 zsh 后HOME/END 键以及小键盘失效)