# Color terminals?



## Anonymous (Dec 23, 2009)

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.


----------



## graudeejs (Dec 23, 2009)

`$ ls -G`

ls()

also you may want to read man of particular terminal to find out who to set colors in ~/.Xdefaults


----------



## oliverh (Dec 23, 2009)

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.


----------



## SirDice (Dec 23, 2009)

If you use (t)csh just add to ~/.cshrc:

```
setenv CLICOLOR
```

Ls will be colored automatically.


----------



## oliverh (Dec 23, 2009)

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.


----------



## mickey (Dec 23, 2009)

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).


----------



## oliverh (Dec 23, 2009)

>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.


----------



## crsd (Dec 23, 2009)

Which applications are you referring to? vim shows colors with TERM set to xterm.


----------



## mickey (Dec 23, 2009)

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.


----------



## oliverh (Dec 23, 2009)

@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.


----------



## mickey (Dec 23, 2009)

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:

There's a problem with the termcap description for your terminal so that mutt doesn't get aware of it supporting color.
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`


----------



## oliverh (Dec 24, 2009)

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.


----------



## Anonymous (Dec 26, 2009)

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?


----------



## sixtydoses (Dec 26, 2009)

You mean like the color list?

`man ls` will give you a list of LSCOLORS values.


----------



## oliverh (Dec 26, 2009)

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:


```
LSCOLORS="ExGxFxdxCxDxDxhbadExEx";    export LSCOLORS
```


----------

