You are not logged in.

#1 2008-09-08 01:45:30

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Custom bash coloring bug?

Hi,

I notice that when I change my console color through the .bashrc file, the LS command results in the color replacement for 'white' not working past the 'blue' items. For example, in the listing for "ls", any blue items that occur will result in the "gray" text instead of the new color meant to replace it. Is there a fix for this?

Offline

#2 2008-09-08 02:18:01

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: Custom bash coloring bug?

void.pointer wrote:

Hi,

I notice that when I change my console color through the .bashrc file, the LS command results in the color replacement for 'white' not working past the 'blue' items. For example, in the listing for "ls", any blue items that occur will result in the "gray" text instead of the new color meant to replace it. Is there a fix for this?

It's hard to say without seeing your setup.  Post your custom colour settings...it's probably a syntax error.


thayer williams ~ cinderwick.ca

Offline

#3 2008-09-08 12:06:17

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Re: Custom bash coloring bug?

Sorry, I should have posted this to begin with:

alias ls='ls --color=auto'
PS1='\[\e[1;36m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[m\] \[\e[1;32m\]\$ \[\e[m\]\[\e[1;37m\] '

Offline

#4 2008-09-08 13:37:08

farmer
Member
Registered: 2008-01-19
Posts: 7

Re: Custom bash coloring bug?

Hi, your PS1 should look like this.

PS1='\[\e[1;36m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] '

If you want to change 'ls' coloring take a look 'man dircolors'

Offline

#5 2008-09-08 15:46:20

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Re: Custom bash coloring bug?

farmer wrote:

Hi, your PS1 should look like this.

PS1='\[\e[1;36m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] '

If you want to change 'ls' coloring take a look 'man dircolors'

I find the PS1 syntax a bit difficult to read. Could you explain the differences in the code you posted and the code I posted? What is your code supposed to correct? I used the exact PS1 provided on the archlinux wiki. Thanks.

Offline

#6 2008-09-08 17:18:54

farmer
Member
Registered: 2008-01-19
Posts: 7

Re: Custom bash coloring bug?

This starts coloring everything after it in turquoise,

\e[1;36m

this sets coloring to default,

\e[m

the backslash bracket tell it to ignore everything between it when calculating prompt lenght,

\[     \]

you left \[\e[1;37m\] at the end coloring evering after it in white. I hope this helps.

Offline

#7 2008-09-08 18:42:38

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Re: Custom bash coloring bug?

farmer wrote:

This starts coloring everything after it in turquoise,

\e[1;36m

this sets coloring to default,

\e[m

the backslash bracket tell it to ignore everything between it when calculating prompt lenght,

\[     \]

you left \[\e[1;37m\] at the end coloring evering after it in white. I hope this helps.

Thanks for explaining, farmer.

You mentioned earlier about using dircolors. I looked into this but I find it a bit confusing. I expected there to be a configuration file somewhere that I change that modifies the colors of the LS output. I realize that the environment variable LS_COLORS is used to configure the colors output by ls, but when I do "echo $LS_COLORS", I get nothing. Where is LS_COLORS being set? Is there a configuration file somewhere I can look at? The man pages mentioned a few files, like /etc/dir_colors, however no such files exist on my system.

Thanks again.

Offline

#8 2008-09-08 19:47:03

farmer
Member
Registered: 2008-01-19
Posts: 7

Re: Custom bash coloring bug?

You can create a config file and modify it.

dircolors -p > ~/.dir_colors

Then add this to your ~/.bashrc

eval `dircolors -b ~/.dir_colors`

Offline

#9 2008-09-08 19:58:43

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Re: Custom bash coloring bug?

farmer wrote:

You can create a config file and modify it.

dircolors -p > ~/.dir_colors

Then add this to your ~/.bashrc

eval `dircolors -b ~/.dir_colors`

Why "eval" instead of just doing 'dircolors' directly?

Thanks for your help.

Offline

#10 2008-09-08 20:24:30

farmer
Member
Registered: 2008-01-19
Posts: 7

Re: Custom bash coloring bug?

It executes the commands printed out by

dircolors -b ~/.dir_colors

command.

Offline

#11 2008-09-09 00:55:52

carlocci
Member
From: Padova - Italy
Registered: 2008-02-12
Posts: 368

Re: Custom bash coloring bug?

void.pointer wrote:

Hi,

I notice that when I change my console color through the .bashrc file, the LS command results in the color replacement for 'white' not working past the 'blue' items. For example, in the listing for "ls", any blue items that occur will result in the "gray" text instead of the new color meant to replace it. Is there a fix for this?

I think this is because you color your commands bold white and ls doesn't set the color for "unknown" files until it is forced to (after displaying something in another color, the most common, a directory).
Is this a bug of ls ?

Offline

#12 2008-09-15 22:10:56

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Re: Custom bash coloring bug?

Hi,

I put the 'dircolors' command in my .bashrc, but now when I login I get the following output in my shell:

LS_COLORS='rs=0:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:';
export LS_COLORS

This happens immediately after I login and type my password in SSH. Why is it doing this, and how can I prevent this output? Thanks.

Offline

#13 2008-09-15 22:20:34

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: Custom bash coloring bug?

void.pointer wrote:

Hi,

I put the 'dircolors' command in my .bashrc

farmer wrote:

You can create a config file and modify it.

dircolors -p > ~/.dir_colors

Then add this to your ~/.bashrc

eval `dircolors -b ~/.dir_colors`

thayer williams ~ cinderwick.ca

Offline

#14 2008-09-15 22:24:27

void.pointer
Member
From: Dallas, TX
Registered: 2008-07-30
Posts: 239

Re: Custom bash coloring bug?

thayer wrote:
void.pointer wrote:

Hi,

I put the 'dircolors' command in my .bashrc

farmer wrote:

You can create a config file and modify it.

dircolors -p > ~/.dir_colors

Then add this to your ~/.bashrc

eval `dircolors -b ~/.dir_colors`

I think you are misunderstanding. I am running "eval", but the commands it is executing is being placed in the output for some reason. My .bashrc is as follows:

eval 'dircolors -b .dir_colors'

However, it places the original text in the output as I posted in my last response.

::EDIT::
TRICKY! The quotes are different! I was using single quotes, not backticks. That was easy to overlook! Now it works just fine!

Last edited by void.pointer (2008-09-15 22:33:47)

Offline

Board footer

Powered by FluxBB