[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Solved] ls color for bad symbolic link



Tong(mlist4suntong@yahoo.com) is reported to have said:
> On Wed, 15 Dec 2004 00:51:22 +0000, Jason Chambers wrote:
> 
> > On Tue, Dec 14, 2004 at 07:29:22PM -0500, Tong wrote:
> >> On Sat, 11 Dec 2004 16:48:34 -0500, Tong wrote:
> >> 
> >> > I remember that my previous distro can distinguish symbolic links as good
> >> > or bad: good links are show as normal link color whereas bad links are
> >> > shown as red. 
> >> > 
> > 
> > [snip]
> > 
> >> Ok, let's take a look at an example:
> >> 
> >> touch a
> >> ln -s a l1
> >> ln -s no l2
> >> rm no
> >> 
> >> ls --color=auto
> >> 
> >> Do l1 and l2 show up in same color? 
> >> 
> >> In my Debian, they are, but in my RH, l2 show up red.
> > 
> > Have you tried doing a eval `dircolors -b` before the ls command?  This
> > defines the LC_COLORS variable that is used to decide what colours are
> > used.  You can get pretty colours for all sorts of things if you want to play
> > about with dircolors but by default broken links are in red, and
> > common image file extension in magenta etc.
> > 
> > IIRC it was already in the bashrc file - it just needed uncommenting.
> 
> Thank you very much Jason! 
> 
> Of all the replies, only yours give the correct answer to my problem
> 
> Just for the archive, as the result, before the eval, both my l1 and l2
> are in magenta, whereas after the eval, l2 show up red.

I have had this snippit in my .bash_profile for 10-12 years.  

# set up the color-ls environment variables:
if [ "$SHELL" = "/bin/zsh" ]; then
  eval `dircolors -z ~/.dircolors`
elif [ "$SHELL" = "/bin/ash" ]; then
  eval `dircolors -s ~/.dircolors`
else
  eval `dircolors -b ~/.dircolors`
fi

Hope this helps somone.

WT

-- 
Every time I type 'win', I loose ...
_______________________________________________________



Reply to: