在 FreeBSD 上的终端中按 ctrl + 箭头键时获得 ;5D

jdo*_*man 29 linux freebsd ubuntu ssh terminal

在 centos 上,我可以通过在终端中按 ctrl + 箭头(向左或向右)来跳过一个单词。当我 ssh 进入 FreeBSD 框并尝试相同的模式时,我得到:

$ tail -f 20120412.log;5D;5D;5D
Run Code Online (Sandbox Code Playgroud)

(每次尝试 = ;5D

有没有办法来解决这个问题?我正在使用 Ubuntu 12.04 + 终结者。

提前致谢。

小智 42

.inputrc主目录中的A将导致ctrl+left停止在 Ubuntu 上工作(例如)。

要使一切正常,请将以下内容添加到~/.inputrc

# Include system-wide inputrc, which is ignored by default when
# a user has their own .inputrc file.
$include /etc/inputrc
Run Code Online (Sandbox Code Playgroud)

  • 澄清一下 - 这个 `.inputrc` 应该在远程机器上设置。 (2认同)
  • 对于完全缺少`.inputrc`的任何人,我的相关行是:`"\e[1;5C": forward-word`、`"\e[1;5D": back-word`、` "\e[5C": forward-word`, `"\e[5D": back-word`, `"\e\e[C": forward-word`, `"\e\e[D":反向词` (2认同)

小智 5

如果您使用 ZSH,则在/etc/zshrc文件中使用它。

case "${TERM}" in
  cons25*|linux) # plain BSD/Linux console
    bindkey '\e[H'    beginning-of-line   # home 
    bindkey '\e[F'    end-of-line         # end  
    bindkey '\e[5~'   delete-char         # delete
    bindkey '[D'      emacs-backward-word # esc left
    bindkey '[C'      emacs-forward-word  # esc right
    ;;
  *rxvt*) # rxvt derivatives
    bindkey '\e[3~'   delete-char         # delete
    bindkey '\eOc'    forward-word        # ctrl right
    bindkey '\eOd'    backward-word       # ctrl left
    # workaround for screen + urxvt
    bindkey '\e[7~'   beginning-of-line   # home
    bindkey '\e[8~'   end-of-line         # end
    bindkey '^[[1~'   beginning-of-line   # home
    bindkey '^[[4~'   end-of-line         # end
    ;;
  *xterm*) # xterm derivatives
    bindkey '\e[H'    beginning-of-line   # home
    bindkey '\e[F'    end-of-line         # end
    bindkey '\e[3~'   delete-char         # delete
    bindkey '\e[1;5C' forward-word        # ctrl right
    bindkey '\e[1;5D' backward-word       # ctrl left
    # workaround for screen + xterm
    bindkey '\e[1~'   beginning-of-line   # home
    bindkey '\e[4~'   end-of-line         # end
    ;;
  screen)
    bindkey '^[[1~'   beginning-of-line   # home
    bindkey '^[[4~'   end-of-line         # end
    bindkey '\e[3~'   delete-char         # delete
    bindkey '\eOc'    forward-word        # ctrl right
    bindkey '\eOd'    backward-word       # ctrl left
    bindkey '^[[1;5C' forward-word        # ctrl right
    bindkey '^[[1;5D' backward-word       # ctrl left
    ;;
esac
Run Code Online (Sandbox Code Playgroud)


小智 0

看来您的 $TERM 设置可能错误。echo $TERM找出您当前的设置。可能想使用 xterm export TERM=xterm-256color