emacs -nw and xterm (Getting xterm to recognize the ALT key)

The terminal emulators I’ve used so far are konsole, gnome-terminal and xterm. Since my RHEL box at work is KDE-based and my ubuntu machine at home is gnome based, konsole and gnome-terminal have received heavy usage. The other day I decided to (re)try out xterm on my ubuntu 10.04. I like xterm and have used it before, but I couldn’t for the life of me remember why I switched back.

Once I started some real work, of course, it all came back to me.

I’m a heavy emacs user and often have emacs running in terminal mode over an ssh session. And xterm by default does not recognize the ALT key. The alternative is the (ugh!) ESC key. This of course can get very frustrating. And if you (like me) are not careful, your source files might end up with the character ÿ scattered all over the place. And so, determined to continue using xterm, I set out to look for a solution.

The most common solution found online was of course to edit the ~/.Xdefaults and/or ~/.Xresources with the following lines-

~ $ cat ~/.Xdefaults | tail -n 3
Xterm*metaSendsEscape:     TRUE
Xterm*altSendsEscape:      TRUE
Xterm*eightBitInput:       false
~ $

and also to edit the .inputrc to have the following lines-

~ $ cat .inputrc 
set meta-flag on
set convert-meta off
set output-meta on
~ $ 

But that still didn’t quite do it for me.

After much digging/reading, I figured out that while ~/.Xdefaults under your home directory has settings for the current user, the file /etc/X11/app-defaults/XTerm contains settings that can be globally applied.

xterm*metaSendsEscape: true

And so adding the above line to the above file allowed XTerm to recognize the ALT key the way emacs likes it.

Posted in config | Tagged , , | 5 Comments

Hello world!

~ $ echo hello world
hello world
~ $

After switching among multiple distros (at school, work and home), I got tired of repeatedly trying to solve the same desktop customization issues just because I couldn’t remember how I did it last time. That’s when I decided to write down the little bits and pieces of information about customizing my linux desktop that I’ve found helpful over the years.

Hope you find them helpful too. Stay tuned!

Posted in Uncategorized | Tagged | Leave a comment