
我最近在新的 ubuntu 設定上安裝了 zsh (v5.1.1),但是當我在 gnome-terminal 中切換到它時,我似乎無法使用 Enter 鍵來執行命令。我執行命令的唯一方法是使用CTRL+J
.我可以在其他術語模擬器(例如xterm
和 )上複製此操作uxterm
。
所有其他按鍵都可以正常工作,包括 HOME、END、PGUP、PGDOWN、DEL 和 INSERT 鍵。
我在其他系統上安裝過zsh
很多次,但以前從未遇到過這樣的問題。我需要更改什麼才能讓 Enter 鍵正常運作?
我的/etc/zsh/zshrc
文件:
typeset -ga debian_missing_features
if [[ -z "$DEBIAN_PREVENT_KEYBOARD_CHANGES" ]] &&
[[ "$TERM" != 'emacs' ]]
then
typeset -A key
key=(
BackSpace "${terminfo[kbs]}"
Home "${terminfo[khome]}"
End "${terminfo[kend]}"
Insert "${terminfo[kich1]}"
Delete "${terminfo[kdch1]}"
Up "${terminfo[kcuu1]}"
Down "${terminfo[kcud1]}"
Left "${terminfo[kcub1]}"
Right "${terminfo[kcuf1]}"
PageUp "${terminfo[kpp]}"
PageDown "${terminfo[knp]}"
)
function bind2maps () {
local i sequence widget
local -a maps
while [[ "$1" != "--" ]]; do
maps+=( "$1" )
shift
done
shift
sequence="${key[$1]}"
widget="$2"
[[ -z "$sequence" ]] && return 1
for i in "${maps[@]}"; do
bindkey -M "$i" "$sequence" "$widget"
done
}
bind2maps emacs -- BackSpace backward-delete-char
bind2maps viins -- BackSpace vi-backward-delete-char
bind2maps vicmd -- BackSpace vi-backward-char
bind2maps emacs -- Home beginning-of-line
bind2maps viins vicmd -- Home vi-beginning-of-line
bind2maps emacs -- End end-of-line
bind2maps viins vicmd -- End vi-end-of-line
bind2maps emacs viins -- Insert overwrite-mode
bind2maps vicmd -- Insert vi-insert
bind2maps emacs -- Delete delete-char
bind2maps viins vicmd -- Delete vi-delete-char
bind2maps emacs viins vicmd -- Up up-line-or-history
bind2maps emacs viins vicmd -- Down down-line-or-history
bind2maps emacs -- Left backward-char
bind2maps viins vicmd -- Left vi-backward-char
bind2maps emacs -- Right forward-char
bind2maps viins vicmd -- Right vi-forward-char
# Make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
function zle-line-init () {
emulate -L zsh
printf '%s' ${terminfo[smkx]}
}
function zle-line-finish () {
emulate -L zsh
printf '%s' ${terminfo[rmkx]}
}
zle -N zle-line-init
zle -N zle-line-finish
else
for i in {s,r}mkx; do
(( ${+terminfo[$i]} )) || debian_missing_features+=($i)
done
unset i
fi
unfunction bind2maps
fi # [[ -z "$DEBIAN_PREVENT_KEYBOARD_CHANGES" ]] && [[ "$TERM" != 'emacs' ]]
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
/usr/local/bin \
/usr/sbin \
/usr/bin \
/sbin \
/bin \
/usr/X11R6/bin
(( ${+aliases[run-help]} )) && unalias run-help
autoload -Uz run-help
# If you don't want compinit called here, place the line
# skip_global_compinit=1
# in your $ZDOTDIR/.zshenv or $ZDOTDIR/.zprofile
if [[ -z "$skip_global_compinit" ]]; then
autoload -U compinit
compinit
fi
答案1
若要輸出 zsh 與每個鍵關聯的字符,請鍵入⌃+,v然後鍵入該字元(其中⌃是Ctrl鍵)。
例如:
- 我的返回鍵輸出:
^M
- 我的輸入鍵輸出:
^[OM
為了讓我的回車鍵表現得像我的返回鍵:
bindkey '^[OM' accept-line