【问题标题】:Can't input any special characters in OS X terminal when using ZSH使用 ZSH 时无法在 OS X 终端中输入任何特殊字符
【发布时间】:2015-10-06 07:38:04
【问题描述】:

当我使用 ZSH shell(带有 oh-my-zsh 插件)时,我无法在 OS X 终端中输入任何特殊字符(例如 äöå)。如果尝试输入其中一个字符,我只会得到默认的 mac 错误声音警报,并且没有可见字符。但是,如果我切换到 bash,一切正常。

终端设置为 utf-8,我的 .zshrc 包含:

export LANG=fi_FI.UTF-8
export LANG="fi_FI.UTF-8"
export LC_COLLATE="fi_FI.UTF-8"
export LC_CTYPE="fi_FI.UTF-8"

我使用的是 OS X Yosemite,我的语言设置为芬兰语。

~  locale
LANG="fi_FI.UTF-8"
LC_COLLATE="fi_FI.UTF-8"
LC_CTYPE="fi_FI.UTF-8"
LC_MESSAGES="fi_FI.UTF-8"
LC_MONETARY="fi_FI.UTF-8"
LC_NUMERIC="fi_FI.UTF-8"
LC_TIME="fi_FI.UTF-8"
LC_ALL=

知道有什么问题吗?

【问题讨论】:

  • 使用iTerm,已知Terminal有这样的问题。

标签: macos character-encoding osx-yosemite zsh oh-my-zsh


【解决方案1】:

~/.zprofile中添加这个shell初始化:

# Correctly display UTF-8 with combining characters.
# This part is included in /etc/zshrc in some recent versions of MacOS
if [ "$TERM_PROGRAM" = "Apple_Terminal" ]; then
        setopt combiningchars
fi
# Don't strip 8th bit
stty -istrip
LANG=fi_FI.UTF-8
export LANG

您不必在 ~/.zshrc 中包含任何内容,因为不必在每个 shell 级别重复。

【讨论】:

    猜你喜欢
    • 2018-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-20
    • 1970-01-01
    相关资源
    最近更新 更多