Sponsored Links

Customize Xterm, the original and best terminal…

There’s all sorts of terminal emulators available these days.

Most of the “modern” ones, like gnome-terminal for example, have lots of whiz-bang features like menu-driven customization, background picture or transparency, setting the font used, and so on.

The thing is, all these nice features introduce their own problems, the biggest one for me is BLOAT.

Gnome-terminal to me is like a monster, with an insatiable appetite for memory and CPU cycles.

I’ve had gnome-terminal using 66% CPU just sitting there looking at me, in an RDP session fer goodness sake! Unacceptable!

Anyway, Xterm is my current choice of terminals for use in RDP sessions (and for general-purpose use). It’s pretty lightweight compared to its KDE and Gnome cousins, and believe it or not it’s actually quite configurable.

Experienced Linux users and admins probably already know the charms of xterm, however I think from time to time it’s good to have a refreshed article, to show Linux newcomers or just basically people who never give xterm a second glance, that xterm is actually a very good (if not the best) terminal of choice ;)

Customize Xterm

Default Xterm – a bit “meh”

 

 

 

If you use xterm in its default configuration, it usually looks plain, the scrollbar is on the left hand side, if there is a scrollbar by default (I prefer mine on the right hand side), and the font is usually not very nice looking and also quite small.

 

 

 

 

 

 

 

I reckon a lot of people just look at it and say “meh!” and bring up gnome-terminal instead when they see that.

However, even Xterm has various menus to customize its appearance. By pressing the CTRL key with a combination of the Left, Middle, or Right mouse keys, you can alter xterm’s appearance and behaviour…

Xterm CTRL+Left Mouse Button Menu

Xterm CTRL+Middle Mouse Button Menu

Xterm CTRL+Right Mouse Button Menu

 

 

 

 

 

 

 

 

Whilst useful, these changes don’t automatically get saved, and are therefore relevant only to that particular running xterm instance. There is however a way to customize and make the changes permanent.

1) Customizing Xterm

Introducing the .Xresources file.

Using this handy file, which you save in your home directory, you just plug in whatever you wish to customize your xterm sessions with.

Here’s my current .Xresources file contents…

! Use a nice truetype font and size by default... 
xterm*faceName: DejaVu Sans Mono Book
xterm*faceSize: 11

! Every shell is a login shell by default (for inclusion of all necessary environment variables)
xterm*loginshell: true

! I like a LOT of scrollback...
xterm*savelines: 16384

! double-click to select whole URLs :D
xterm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48

! DOS-box colours...
xterm*foreground: rgb:a8/a8/a8
xterm*background: rgb:00/00/00
xterm*color0: rgb:00/00/00
xterm*color1: rgb:a8/00/00
xterm*color2: rgb:00/a8/00
xterm*color3: rgb:a8/54/00
xterm*color4: rgb:00/00/a8
xterm*color5: rgb:a8/00/a8
xterm*color6: rgb:00/a8/a8
xterm*color7: rgb:a8/a8/a8
xterm*color8: rgb:54/54/54
xterm*color9: rgb:fc/54/54
xterm*color10: rgb:54/fc/54
xterm*color11: rgb:fc/fc/54
xterm*color12: rgb:54/54/fc
xterm*color13: rgb:fc/54/fc
xterm*color14: rgb:54/fc/fc
xterm*color15: rgb:fc/fc/fc

! right hand side scrollbar...
xterm*rightScrollBar: true
xterm*ScrollBar: true

! stop output to terminal from jumping down to bottom of scroll again
xterm*scrollTtyOutput: false

 

Note that comments start with a “!”.

Copy and paste that into a file called .Xresources in your home directory.

Then issue the following command;

xrdb -merge ~/.Xresources

That will tell your X server to incorporate those tweaks, and saves having to log out and back in again.

Then run a new xterm and it’ll look like this;

Xterm With Nicer Defaults

 

 

 

 

 

 

 

 

 

 

Which in my opinion looks much nicer than the distro-supplied defaults. Also, one of the tweaks above will get Xterm to select whole URL’s displayed in the xterm window, which is a very handy feature. And I’ve selected DosBox-like screen coloring, which I find quite nice.

2) Cutting and pasting with Xterm

Cutting text with xterm is pretty much the same as with gnome terminal. The difference being that any text you select, automatically gets placed into the clipboard.

  • Drag the mouse cursor along the text you wish to copy whilst holding down the LEFT mouse button.
  • double-clicking on a word will select that word (or if you’ve included my tweaks it’ll select a whole URL)
  • triple-clicking on a line will select that line

Pasting text is also pretty straightforward; just click the MIDDLE mouse button into an xterm window and the text in the clipboard will be pasted in.

3) Scrolling using the mouse

  • LEFT clicking on the scrollbar scrolls DOWN a bit
  • MIDDLE clicking and HOLDING on the scrollbar drags the scroll window up and down
  • RIGHT clicking scrolls UP a bit

 

There are a bazillion other tweaks which can be performed using this method. I’ll update this article when I find new hotness for xterm.

Do you have any additional tweaks for Xterm or an opinion on your favourite terminal of choice?

Post them in the comments below!

 

VN:F [1.9.22_1171]
Rate This Article
Rating: 9.8/10 (127 votes cast)
Customize Xterm, the original and best terminal..., 9.8 out of 10 based on 127 ratings
Share the knowledge :
Facebook Twitter Pinterest Linkedin Digg Delicious Reddit Stumbleupon Posterous Email Snailmail

52 comments to Customize Xterm, the original and best terminal…

  • I am NEW to Linux and somewhat sight impaired. Hence my need to customise fonts in Xterm.

    I follow instructions and paste the script for .Xresources into Nautilus,  I cannot then save the file as .Xresources only as Xresources

    If I start Nautilus from Xterm with SUDO Nautilus, then I cannot find the  HOME directory or the previously saved Xresources file. However I do seem to have the permission needed to save a . (dot) file

    Can you help me further please?

     

    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
    • Kevin Cave

      Hi John,

      Your home directory is located at /home/<username>/ , so, say for example your login user name is “john” , then your home directory should be located at /home/john/ .

      Since you’re new to linux, I suggest you use a text editor such as gedit , for example. In which case you should;

      1) Start gedit – which is available in the default Ubuntu installation and should be under the Accessories menu. You don’t have to edit the file as a superuser/using sudo.

      2) Copy and paste the example .Xresources contents in my Howto above into the blank document.

      3) Select File then Save As, in the gedit menu, then when the directory browser window appears, make sure you are in your home directory.

      I’ve included a screenshot of the gedit file browser for your convenience;

      The red rectangle shows the name of the file to be saved : .Xresources

      Using the part of the file browser I’ve highlighted using the green rectangle, you can click through to your home directory – in my case /home/kcave as used in a virtual machine of mine…

      You can also find your home directory using the area I’ve highlighted in yellow – your home directory should be listed just above “Desktop”.

      Screenshot of file browser

       

      Hope this helps! Let me know how you got on :)

      Regards!

      VN:F [1.9.22_1171]
      Rating: +10 (from 10 votes)
  • Thanks a million Kevin. It worked straightforwardly.

    I would however be more comfortable with the default size “large”. This I can do with <Ctl Rt click> but it would be good to know which line to change in the .Xresources script.

    John

    VA:F [1.9.22_1171]
    Rating: +2 (from 2 votes)
    • Kevin Cave

      Hey John, glad that worked out for you :)

      You can change the default font size by altering this line;

      xterm*faceSize: 11

      Just increase or decrease the font size to your taste.

      Regards!

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • Hi. Kevin, My previous message was written in elation and haste – before I switched my brain on.

    I think I am getting thr hang of things. (previously I did not realise that gedit shows up as “text editor” on my desktop.

    I have used gedit and changed the facesize figure from 11 to 15. Re-saved .Xresources and again run the command xrbp…etc. This now gives me a default screen in Xterm that I can read comfortably.

    Info xrbp gives me some idea of what I am doing, but I can get no response to “man merge” or “info merge” to appreciate what is happening.

    Anyway thanks again for your prompt help.

    Regards,

    John  (Millom, UK)

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • Kevin Cave

      Hi John,

      -merge” is the option given to the xrdb command itself, so that’s why you won’t see relevant information if you just look up “info merge” or similar :)

      If you type “man xrdb” in an xterm window, you’ll get the xrdb manual page, and within that you’ll see what the “-merge” option does.

      Regards!

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • Thanks, I have sent a small donation.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • David Wall

    I totally agree with your affection for xterm over gnome-terminal.

    However, I find that my favorite font (lucidasanstypewriter-10) in gnome-terminal under ubuntu 10.4 looks fine, but in xterm it looks muddy and jagged.  My guess is that this is because of the “subpixel smoothing” that I get via System > Preferences > Appearance > Fonts, but I don’t really know.  Is there any way to sort this out?

    Thanks!

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • David Wall

    Good thought, but that description doesn’t match what I’m seeing.  Ah well.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • Kevin Cave

      Hi David, lemme look into it – installing an Ubuntu 10.04 installation now… you’ve piqued my interest ;)

      VN:F [1.9.22_1171]
      Rating: +1 (from 1 vote)
    • Kevin Cave

      David,

      I installed Ubuntu 10.04 in a VM, performed all the updates, made sure subpixel smoothing was on, installed the sun-java6-fonts package (which provides the Lucida Sans Typewriter), and set my .Xresources file such that the font settings are thusly;

      xterm*.faceName: Lucida Sans Typewriter Regular
      xterm*.faceSize: 10

      I could not replicate your symptoms in the VM.

      Tell me, are you using a gnome desktop with compiz running (i.e. desktop effects)?

      Do you still get the same symptom when running the gnome failsafe session?

      Regards,

      Kev.

       

       

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • I canot scroll xterm using mouse or keyboard. I start xterm by `xterm -e tmux`.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • sw2wolf, hi

      I canot scroll xterm using mouse or keyboard. I start xterm by `xterm -e tmux`.

      Er, that’s because you’re kind of bypassing the xterm’s scrollback buffer, because you’re actually in a tmux session. If you want to scroll back, you need to place tmux into “copy mode”. Refer to the tmux documentation on how that’s handled.

      Hope that helps!

      Regards

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • zoro

    Hi All,
    First of all , all of this has given me a great insight about the xterm  and I really appreciate your comments. you guys are great.
    well, I am new to Linux, and i found this is great place to ask my doubt.
    I run xterm& command  in my gnome terminal , and got xterm terminal pop-up.
    But  I am not able to see any Menus,when I am pressing ctrl+ right click of mouse.
    similarly , I can not see VT options and while pressing ctrl+ middle key.
    in short, any ctrl and mouse key combination is not working for me.
    Any buddy can suggest me , what can be done in this case to see "enable"  these options.
    Any help will be appreciated.
    Thanks a lot
     

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Andrew

    I've also found this article super helpful as a newcomer to Linux.  I've been trying to increase the scrollback buffer size and haven't been able to quite crack the code.  Any help with this would be appreciated.

    Also, I'm currently happy with everything else about Xterm.  If I create a .Xresources file that contains only the bits required to increase Xterm's scrollback buffer will all the other parameters of Xterm remain unchanged?

    Thanks!

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • Hi Andrew, and thanks.

      If you add or edit the entry in your .Xresources file :

      XTerm*saveLines

      That will change the amount of scrollback your xterm has. And yes, if you only had that one line in the file, you will get the rest of xterm’s default settings.

      Hope this helps.

      Regards

       

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • Andrew

    That worked out great!  Thanks again for sharing your knowledge.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • The config line 

    xterm*ScrollBar: true

    Should be

    xterm*scrollBar: true

    to work as expected.

    Except that, all works fine and help me a lot and save me a long time. Thx

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Chris Jones

    My tweak/advice would be to replace the ‘DejaVu Sans Mono’ ttf font by a decent bitmap font. :-)

    The glyphs in outline/vector fonts such as truetype have to be automatically converted to bitmaps in order to being displayed.. because with very rare exceptions computer screens are… bitmaps: they are made up of pixels. Hence, truetype fonts have to be rasterized prior to being displayed. And there is no way the best rasterizing software can come close to a talented font designer manually tweaking his bitmap fonts. The result ranges from passable to downright atrocious..!

    The downside is that you must use a bitmap font designed for the exact point size you want.. ttf font rasterization is far from perfect but never quite as horrendous as what you get when you let your X server try to scale a bitmap font.

    Except for those of us who have serious problems with their eye vision, and may need unusually large fonts as a result (16 points and above..?) finding a good monospace bitmap font should not be too difficult.

    But for most users, there is no point in using a .ttf font on a terminal.

    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
    • Chris, thanks for the input…

      If you have any specific fonts you like to use, feel free to mention them here :)

      Regards

      Kevin.

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • John

    how do you change default window size within that ~/.Xresources ?

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • sia

    Great post! Thanks tons!

    I have been using Gnome-terminal for a while, but after a recent update, I noticed if I divide my “screen” in to two parts, and one of them is echoing text to the terminal, the other half of screen becomes unresponsive. Very annoying. Sure enough, XTerm did not have the problem, but it was ugly. Thanks for sharing your configuration which solved the ugliness problem.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Xrdpuser

    x11rdp works ok on Kubuntu. However contrary to what you mentioned above as your preference, I prefer a transparent terminal (Gnome terminal, Konsole or Guake). Also, when logging out of an RDP session, the session closes but the RDP window stays open. Also noticed if you have Krusader last connected to a Windows computer, when you run it, the Windows authentication dialog box pops up but it’s blank and you can’t authenticate to the windows computer that was connected previously. And if you try to run Krusader in Root mode, it’s also blank.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Jim

    I have always preferred xterm because it is fast, neat, and simple with a compact and readable font that is not available in other terminals. Nobody really wants transparent backgrounds and goofy fonts when they are working.

    VA:F [1.9.22_1171]
    Rating: 0 (from 6 votes)
  • Shane Scott

    I thank you very much.

    Using the terminal on my new Chromebook – without an external mouse – was a serious pain until I found this page.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • hongmei

    Very useful, thanks a lot!

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Paps

    Worked perfectly, I thought the default Xterm look really ugly, and now it’s just as I want.
    Really, thank you!

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Mike Nelson

    Best .Xresources I’ve tried ever! Wish these were the defaults.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • ayy

    umm i have a cursor that remains a static blue
    nothing has changed it

    VA:F [1.9.22_1171]
    Rating: -1 (from 1 vote)
  • Tomasz

    THANKS !!!! really helpfull . Default of xterm is ugly and unreadable – that was changed my point of view

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Pali

    Hi,

    I have ~/.Xresources file with xterm settings, but it is useless on KDE out here.
    Xterm window is different then it should be according to .Xresources settings.

    Why is not used .Xresources here on KDE Plasma-5 DE?

    Best, Pali

    VA:F [1.9.22_1171]
    Rating: -1 (from 1 vote)
  • Petryn

    Very good guide, as you can enlarge the letters and change of color to the writing of the XTerm?

    VA:F [1.9.22_1171]
    Rating: -2 (from 2 votes)
  • LarryC

    I make the following changes in /etc/X11/app-defaults/XTerm

    *saveLines: 16384
    *scrollBar: true

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Shahriyar

    Unbeliavable! @KevinCave thanks a lot!
    I have did the same steps in my Solaris 11.3 and it worked flawlessly!
    The only thing is that it doesn’t scroll up/down with mouse clicks (from laptop touchpad) but I can use Shift+Up/Down keys for scrolling.
    Now, looking forth to change fonts and some colors.

    Thank you very much again!

    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  • Walter Ulmke

    I’m wondering if someone can help me.
    I have a datbase application with menus, where menu choices are hightlighted by inversing them.
    Sine my latest distri update these menus don’t work any more, and the datbase fields are garbled.
    Does anyone have an idea what’s happening?

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • G C Y

    Cut and paste works fine for me, provided it is from and to xterm.
    With xfce4-terminal I am able to cut from anywhere and paste into the terminal.
    Is there any way this can be achieved with xterm?

    I found your article most helpful, as I have struggled for ages with the complextity
    of xterm’s man page.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Fajar Arch

    Thank very much…

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Robert

    Dude!

    You managed to pull off the perfect xterm setup for me.
    My gratitude will hunt you till the end of times! :-)

    cheers,
    Robert

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • John Weigandt

    Hey Kevin. I was a donor (small amt) and user of x11rdpomatic several years ago to set up multi user rdp sessions for my vet clinic.
    Not sure if you are aware, but on the latest Ubuntu there is now a module called xorgxrdp that is a replacement for x11rdp.
    Bottom line, it works out of the box, with no re compile, and gives all the capability of running multi user rdp sessions
    that you helped us achieve with the script for all these years, but now it’s no fuss no muss no re compile, works out of the box

    In short, you’ve been obsoleted :-)

    It may be one of the best kept secrets in linux right now, which boggles my mind..

    Thanks again for all your efforts that you shared.. John

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • Hi John,

      I remember you :)

      I’m glad it’s obsoleted, I’m just glad it helped folks out at the time :)

      Best regards,

      Kevin.

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • Praful Soni

    Hi Kavin,

    I just get the error below —

    Okay, will just do the install from start to finish with no user interaction…
    ———————————————————————-
    Using the following xrdp configuration : –prefix=/usr
    ———————————————————————-
    Debian package version number will be : 0.9.9+master
    ———————————————————————-
    *** Will remove the contents of /opt/X11rdp and /home/hmc/Desktop/X11RDP-o-Matic-master/work/xrdp-0.9.9+master ***

    running apt-get update
    Checking for previously generated packages…
    ———————————————————————-
    Downloading xrdp source from the GIT repository…
    Cloning into ‘/home/hmc/Desktop/X11RDP-o-Matic-master/work/xrdp’…
    remote: Enumerating objects: 409, done.
    remote: Counting objects: 100% (409/409), done.
    remote: Compressing objects: 100% (383/383), done.
    remote: Total 409 (delta 82), reused 122 (delta 17), pack-reused 0
    Receiving objects: 100% (409/409), 737.31 KiB | 601.00 KiB/s, done.
    Resolving deltas: 100% (82/82), done.
    Checking connectivity… done.
    patch: **** Can’t change to directory /home/hmc/Desktop/X11RDP-o-Matic-master/work/xrdp/xorg/X11R7.6 : No such file or directory

    I tried creating folder xorg & X11R7.6 manually also but as soon as I run the script it remove that folder and get the same error.

    Please give me solution as I tried installing xrdp on my ubuntu 14.04.5 from various sources and options but not able to enable RDP.

    Finally I see your package and tried installing with your script but having problem.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Vinnicius Pavão

    If the ‘xrdb -merge ~/.Xresources’ command fails, now you need to install x11-xserver-utils.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Bodo Thiesen

    For me “xterm*saveLines” works better than “xterm*savelines” because it seems, that resource is case sensitive.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • j adams

    Hi Kevin,

    Great stuff, really helpful. I have now changed my xterm based on your .Xresource file.
    Thank you

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Mon

    Hello, many thanks for this post. I’ve been wanting to switch to the lightest possible terminal for a while now. I was just wondering if there is any way to disable the automatic copy whenever text is selected, and map the ‘copy’ function to a keybinding instead? And the same for the ‘paste’ function too, I’ll need a keybinding because my laptop’s touchpad does not have a middle button.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Thanks Kevin!!

    I’ve been working with xterm since the beginning of my time,
    but only now, at 52, and 10+ years of being sysadmin,
    I got a brainwave from above, and realize its configurable.

    Right in time, my eyesight is getting bad, and xterm
    combined with the awesome window manager (recently?) got
    problems with refreshing the xterm screen.
    Don’t know if this resolves the issue, but I don’t have to
    squeeze at the screen all day long and make my co-workers
    think I’m angry all day :P

    Thanks,

    Michael

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

This site uses Akismet to reduce spam. Learn how your comment data is processed.