使用 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

修改终端属性

但是注意,改用 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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值