Color terminals?

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
I've been looking all over the place but can't seem to find out how to do this. I am trying to get my terminal to be colored so that the prompt has it's own colors and the different kinds of files do to. I am using bash w/ urxvt.
 
mharvey87 said:
I've been looking all over the place but can't seem to find out how to do this. I am trying to get my terminal to be colored so that the prompt has it's own colors and the different kinds of files do to. I am using bash w/ urxvt.

E.g. setting term to xterm-color ; to get color with ls you have to run it with option -G or set an alias for it.
 
If you use (t)csh just add to ~/.cshrc:
Code:
setenv CLICOLOR

Ls will be colored automatically.
 
Most applications are looking for TERM set to xterm-color, e.g. Vim. I don't know what CLICOLOR stands for or which variables it sets.
 
oliverh said:
Most applications are looking for TERM set to xterm-color

Whether an application that is capable of using colors will make use thereof is mostly determined by the corresponding terminal capabilities being present in the terminal's termcap(5) / terminfo(5) entry.

$ tput Co
Outputs the number of colors the terminal is capable of displaying, according to the currently selected terminal type.

The environment variable [CMD=]CLICOLOR[/CMD] is only used by $ ls and, if defined, is equivalent to $ ls -G which enables colored output. Additionally [CMD=]CLICOLOR_FORCE[/CMD] may be defined in order to force $ ls to use colorized output even if the output does not go to a terminal, i.e. piping output to another program. [CMD=]LSCOLORS[/CMD] may be used to override the default set of colors, used for diplaying files of various types; Refer to ls(1) for a detailed description.

The pager more(1)/less(1) has commandline options -r and -R for allowing color control sequences to pass through unhindered. So something like $ ls -G | more -R should work, provided [CMD=]CLICOLOR_FORCE[/CMD] is set (see above).
 
>by the corresponding terminal capabilities being present in the terminal's termcap(5) / terminfo(5) entry.

Of course but in practice you have to set it to see actually colors. There are different examples of applications, that won't show a glimpse of color without setting TERM.
 
oliverh said:
Of course but in practice you have to set it to see actually colors. There are different examples of applications, that won't show a glimpse of color without setting TERM.

What applications would that be?

In that case the application is clearly misbehaving and conceptually wrong.

Most applications will use the ncurses library and thus have not much to deal with these sort of things.
 
@mickey

E.g. Mutt, but I have to confess, this problem first occured with FreeBSD 8.0 (just black and white). I have the some configuration suitable for different systems I work with. Whereas I didn't have any problems for example with mc. In OpenBSD for example this is the usual way to get color support in xterm.
 
oliverh said:
@mickey

E.g. Mutt, but I have to confess, this problem first occured with FreeBSD 8.0 (just black and white). I have the some configuration suitable for different systems I work with. Whereas I didn't have any problems for example with mc. In OpenBSD for example this is the usual way to get color support in xterm.

I have never used mutt, but there are two possibilities why it doesn't display correctly:
  1. There's a problem with the termcap description for your terminal so that mutt doesn't get aware of it supporting color.
  2. They use some custom detection mechanism for color support, which doesn't work for some reason.
Normally programs would use ncurses(3) in order to display on a terminal. As for color support, more specifically features from curs_color(3). So there isn't really much for an application to do, other than asking ncurses, whether the current terminal supports color or not.

What do these output on your terminal?
$ tput Co
$ tput pa
 
My fault: xterm-color and xterm are the same since FreeBSD 5.0 and I didn't really change my behavior (config files) since 5.0. So xterm-color is at least obsolete in FreeBSD.

Btw. it's possible to use Mutt also with slang instead of ncurses. Elinks (console browser) e. g. needs TERM or you can adjust something similar in Elinks itself.
 
ls -g was what I was looking for, now I just have to figure out how to change the colors, the default directory is a dark blue that I can hardly see. Does anyone know where I can find a list of the bash color escape sequences by the way?
 
mharvey87 said:
ls -g was what I was looking for, now I just have to figure out how to change the colors, the default directory is a dark blue that I can hardly see. Does anyone know where I can find a list of the bash color escape sequences by the way?

Something like this:

Code:
LSCOLORS="ExGxFxdxCxDxDxhbadExEx";    export LSCOLORS
 
Back
Top