加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell – Zsh zle shift选择

发布时间:2020-12-16 01:08:25 所属栏目:安全 来源:网络整理
导读:如何使用shift来选择命令行的一部分(就像许多文本编辑器一样)? shift-arrow() { ((REGION_ACTIVE)) || zle set-mark-command zle $1}shift-left() shift-arrow backward-charshift-right() shift-arrow forward-charshift-up() shift-arrow up-line-or-hist
如何使用shift来选择命令行的一部分(就像许多文本编辑器一样)?
shift-arrow() {
  ((REGION_ACTIVE)) || zle set-mark-command
  zle $1
}
shift-left() shift-arrow backward-char
shift-right() shift-arrow forward-char
shift-up() shift-arrow up-line-or-history
shift-down() shift-arrow down-line-or-history
zle -N shift-left
zle -N shift-right
zle -N shift-up
zle -N shift-down

bindkey $terminfo[kLFT] shift-left
bindkey $terminfo[kRIT] shift-right
bindkey $terminfo[kri] shift-up
bindkey $terminfo[kind] shift-down

这假设您的终端在Shift-Arrows上发送一个不同的转义序列来自Arrow发送的转发箭头,并且您的terminfo数据库已正确填充相应的kLFT和kRIT功能,并且您正在使用emacs样式键绑定.

或者,稍微分解代码:

shift-arrow() {
  ((REGION_ACTIVE)) || zle set-mark-command
  zle $1
}
for key  kcap seq        widget (
    left  LFT $'e[1;2D' backward-char
    right RIT $'e[1;2C' forward-char
    up    ri  $'e[1;2A' up-line-or-history
    down  ind $'e[1;2B' down-line-or-history
  ) {
  functions[shift-$key]="shift-arrow $widget"
  zle -N shift-$key
  bindkey ${terminfo[k$kcap]-$seq} shift-$key
}

上面是terminfo数据库没有信息的情况下的硬编码序列(使用xterm序列).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读