Because FLOSS is handy, isn’t it?

Unicode in the command line

Posted by isilanes on November 20, 2007

This is a short HowTo for making unicode work in Linux, specifically in the command line. Yet more specifically, in the konsole terminal. This is useful if you want to be able to use characters like ‘ñ’ or accents like in ‘á’ and ‘ö’.

1 – Modify your shell locale variables

You need locale settings that support UTF (for example en_US.UTF-8). For that, you can add the following lines to .tcshrc or whatever script run at login:

setenv mylang   en_US.UTF-8
setenv LANG     $mylang
setenv LC_CTYPE $mylang
setenv LANGUAGE $mylang
setenv LC_ALL   $mylang

The ‘$mylang’ thing is just because I’m lazy, and I might want to change them all in the future, and I don’t want to type too much.

2 – Modify your global locales

I don’t know if this is needed, but it doesn’t hurt. In Debian:

% dpkg-reconfigure locales

and follow the instructions, using en_US.UTF-8 or something similar as default.

3 – Modify the encoding of Konsole

In the menus:

Settings->Encoding->Unicode (utf8)

Make this permanent with:

Settings->Save as Default

Then choose xterm and not linux as keyboard setting:

Settings->Keyboard->Xterm (XFree 4.x.x)

You can make this permanent in the Session tab of:

Settings->Configure Konsole

namely inserting “xterm” in the box labeled “$TERM”.

If you follow these instructions, you will be able to introduce non-ASCII text in the terminal, and use non-ASCII filenames without problem.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: