[Tfug] Changing xterm colors

Adrian choprboy at dakotacom.net
Fri Oct 13 16:16:49 MST 2006


On Friday 13 October 2006 15:01, Matt Jacob wrote:
> At work, I have access to a few boxes via SSH. One is running Red Hat,
> and one is running Gentoo. The RH box uses a really dark shade of blue
> for directories (when using ls --color) and also for comments in vim.
> My terminal background is black, so dark blue on black is nearly
> impossible to read. The Gentoo box uses a brighter shade of blue,
> which I can actually read against the black background.
> 
> The question: How do I change my color settings on the RH box to make
> them the same as the Gentoo box? I've checked out setterm, and I think
> that may be what I want, but I'm confused as to what exactly I need to
> do. Any ideas?
> 
> If all of this has been thoroughly confusing, I can post screen shots
> to illustrate the difference.
> 

As in all things *nix... it can be in any number of different locations 
depending on your particullar distro. As for the directory colors... I would 
start by looking at /etc/profile.d/colorls.sh (or colorls.csh for csh shells) 
which is probably what is commanding the color preferences (this can change 
as some distros makeup term scripts that look in completely different places 
for the same thing based on wether term is local/remote/xterm...). That 
colorls.sh probably looks for a .dircolors in your home and, if not found, 
a /etc/DIR_COLORS. The later contains the system defaults, capable of being 
over-ridden in a local .dircolors.

As for vim, This is a huge, ugly mess. Start with the /etc/vimrc file 
(optionally make a .vimrc copy in your home to not change global settings). 
Syntax highlighting in vim is set individually, based on what type of file 
vim "thinks" you are editing, for each type. There is an overall 
enable/disable highlighting is set in /etc/vimrc (.vimrc).... Checking my 
system, the actual highlighting properties for 
comment/function/variable/string/etc. are a tangled mess of included 
redirects in /var/share/vim/<vim-release>/.

Say you are editing a C file, the syntax description is defined in 
"/var/share/vim/<vim-release>/syntax/c.vim". In that file there should be a 
number of highlight "HiLink" directives which reference something else... 
which may be locally or remotely defined. For instance, a comment line 
"cCommentL" is defined as a "cComment" highlight, which is itself defined 
later as a "Comment" highlight:

  ...
  HiLink cCommentL              cComment
  ...
  HiLink cComment               Comment
  ...

"Comment" itself may be defined separately in one of several possible color 
schemes in the /var/share/vim/<vim-release>/colors/ directory (set in 
the /etc/vimrc). So "Comment" could be the source compiled definition, or a 
color scheme definition... For instance, I believe the compiled default is 
"darkblue". However, the "pablo" scheme redefines it as #808080 for a gui and 
the "torte" scheme redefines it as #80a0ff for gui'd and "blue" for 
console'd.

pablo.vim:
highlight Comment    ctermfg=8                        guifg=#808080

torte.vim:
highlight Comment    guifg=#80a0ff
...
highlight Comment    ctermfg=Blue

The distro you want to change may or may not have changed the compile time 
colors and may or may not have setup a distro color scheme... so good luck!!! 
Personally, when I want the interaction and colors I am used to, I normally 
just copy  the /etc/vimrc from the system I like to the system I don;t... and 
it is "close enough".

Adrian




More information about the tfug mailing list