UTF-8 字符在 tmux 中未正确显示

Sou*_*abh 33 prompt utf-8 tmux

?在我的zsh主题中使用字符来提示。但是在 tmux 中,我的提示表现得很奇怪,显示了额外的空格,如下所示:

? ~   I can type from here
? ~ Instead of here like in zsh, and sometimes when I do stuff like cd
? ~   cd ~
? ~ cdcd /
? ~ ^^These 2 chars just show up but are not actually part of command and not delete-able
Run Code Online (Sandbox Code Playgroud)

我最近发现我可以通过 .tmux 将 tmux 编码设置为 utf8 set-window-option -g utf8 on。这样做,空间问题消失了,但?字符变为_. 我怎样才能?回来tmux

我的 zsh 主题:

PROMPT='%{$fg_bold[cyan]%} ? %{$fg[blue]%}%c%{$fg_bold[blue]%}$(git_prompt_info)$(git_remote_status)%{$fg_bold[blue]%} % %{$reset_color%}'
Run Code Online (Sandbox Code Playgroud)

Sou*_*abh 53

u标志启动 tmux解决了这个问题

tmux -u
Run Code Online (Sandbox Code Playgroud)

我在 zshrc 中创建了 tmux 的别名

alias tmux='tmux -u'
Run Code Online (Sandbox Code Playgroud)

  • 感谢国旗!使用 tmux 时所有的胡言乱语令人沮丧,而 nvim 会为 powerline 发疯!这解决了问题!再次感谢。 (2认同)
  • 有趣的。我认为在 `~/.tmux.conf` 中设置 `set -g utf8 on` 可以解决这个问题,但显然没有。不过,在调用 `tmux` 时显式使用该标志确实有效。非常感谢,你省了我很多麻烦! (2认同)
  • 只是一个注释。该设置似乎没有保存在会话中。分离后,应该/可以使用“tmux -u Attach”将会话设置为 UTF-8。 (2认同)

小智 13

感谢您的标志部分,但我们也可以将以下内容设置为配置文件 rc (例如.zshrcbashrc)文件

export LC_ALL=en_IN.UTF-8
export LANG=en_IN.UTF-8
Run Code Online (Sandbox Code Playgroud)

设置此选项后,无需使用 -u 标志。