修复 Mac OS X 新版 Terminal 在 SSH 时候出现的 LANGUAGE WARNING

自从升级了新版的 Mac OS X 之后,使用 Terminal SSH 到别的机器上总是能看到这样的警告:

-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

在执行 perl 脚本的时候还能看到这样的警告:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

找了很多方法,包括改服务端 sshd config 什么的,都觉得不好。因为这应该不是服务端的问题,不应该在服务端解决。于是仔细搜索之后发现这个回答完美解决了这个问题:

http://stackoverflow.com/questions/2499794/how-can-i-fix-a-locale-warning-from-perl/7413863#7413863

Here is how to solve it on Mac OS Lion (10.7):

Add the following lines to your bashrc or bash_profile on the host machine:

# Setting for the new UTF-8 terminal support in Lion
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

If you are using zsh, edit zshrc:

# Setting for the new UTF-8 terminal support in Lion
LC_CTYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8

CC BY-NC-SA 4.0 修复 Mac OS X 新版 Terminal 在 SSH 时候出现的 LANGUAGE WARNING by 桔子小窝 is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

发表回复

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据