Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

So these past few days I am working to make Xterm and tmux show all the 256 colors available in them by default. I reach these conclusions:

  • for tmux to show 256 colors you have to make xterm to show it.
  • export TERM=xterm-256color in ~/.bashrc make xterm to show all 256 color. but this is problematic; when you do that you set the whole terminal to xterm and even urxvt will report back its $TERM as Xterm not rxvt-unicode-256color.

So I am looking for the way to just target the xterm. and leave other terminal emulators alone.

PS: I had the same problem ith Urxvt but I solved it by tweaking its Makefile and removed --with-rxvt

share|improve this question

2 Answers 2

To do this specifically for xterm, add the following line to your ~/.Xresources file:

xterm*termName: xterm-256color

The reload your .Xresources with:

xrdb ~/.Xresources

Or logout then back in again.

Another option would be to add the following to your .bashrc (or equivalent file that will be sourced when your shell starts):

[ "$TERM" = xterm ] && export TERM=xterm-256color

The only danger with this is that many other terminals that are not actually xterm set TERM to xterm. If you find yourself using one like this that does not support 256 colours, you may have issues.

share|improve this answer
    
First is it xterm*termName or Xterm*termName and the second what is the .Xresources line for screen (tmux). –  r004 Jun 16 at 2:31
1  
Either xterm*termName or XTerm*termName work for me. Not Xterm*termName though. I don't understand what you mean by 'what is the .Xresources line for screen (tmux)?' screen and tmux are not affected by .Xresources. –  Graeme Jun 16 at 7:49
    
thanks I want to know exactly "screen and tmux are not affected by .Xresources." –  r004 Jun 16 at 9:24
1  
Arch has a good wiki page on .Xresources. It is really only relevant for applications that use the XWindow system directly (like xterm). tmux and screen are terminal applications and do not use the window system at all. Are you maybe looking for how to make xterm start tmux or screen by default instead of the user's shell (bash in most cases). –  Graeme Jun 16 at 9:38

Add

case "$TERM" in
xterm*)
  TERM=xterm-256color;;
rxvt*)
  ;;
*)
  ;;
esac

to your .bashrc

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.