Tuke
Tuke

Reputation: 31

Can't input any special characters in OS X terminal when using ZSH

I can't input any special characters (e.g., äöå) in OS X terminal when I'm using ZSH shell (with oh-my-zsh plugin). If a try to input one of those characters I only get the default mac error sound alert and no visible characters. However, if I switch to bash, everything works correctly.

The terminal is set to utf-8 and my .zshrc contains:

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"

I'm using OS X Yosemite and my language is set to finnish.

~  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=

Any idea what is wrong?

Upvotes: 2

Views: 1143

Answers (1)

athena
athena

Reputation: 203

Add this shell initialization within ~/.zprofile:

# 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

You don't have to include anything inside ~/.zshrc since this doesn't have to be repeated at each shell level.

On the same topic see also this old answer: zsh and international characters.

Upvotes: 0

Related Questions