DIR_COLORS

I would like to know, how to rid of the highlighting when a directory has full write permission?

I only see the DIR option in dir_colors, is there any other option I can manipulate?

DIR_COLORS? This is not DOS. Also it has nothing to do with the directory, it’s a global setting.

Your LS_OPTIONS is probably ‘-N --color=tty -T 0’. It’s the --color=tty that’s doing it.

Yes ken, the LS_OPTIONS show color. But, /etc/DIR_COLORS modifies the behaviour of the LS_OPTIONS? I like the color display with ‘ls’; but, I want to know how to rid of the directory highlighting.

Well that file DIR_COLORS is well commented, so why not try commenting out this line or setting the attribute to 00?

DIR    01;34    # directory

No!

rpm -qf /etc/DIR_COLORS
aaa_base-extras-11.4-54.68.1.x86_64

Not really.

No, it rewrites LS_COLORS. See:

echo $LS_COLORS

It should be overwritten by ~/.dir_colors by the way or have any other name in the colorls.sh or colorls.csh scripts (that I’m not able to find under openSUSE right now).

I like the color display with ‘ls’; but, I want to know how to rid of the directory highlighting.

There are the STICKY_OTHER_WRITABLE and OTHER_WRITABLE variables, which are commented out by default, because they are (definitely) buggy under chs. Try to uncomment and redefine them.

Fedora provides /etc/profile.d/colorls.sh and /etc/profile.d/colorls.csh in coreutils. Here’s how colorls looks like:

# color-ls initialization

#when USER_LS_COLORS defined do not override user LS_COLORS, but use them.
if  -z "$USER_LS_COLORS" ]; then

  alias ll='ls -l' 2>/dev/null
  alias l.='ls -d .*' 2>/dev/null


  # Skip the rest for noninteractive shells.
   -z "$PS1" ] && return

  COLORS=

  for colors in "$HOME/.dir_colors.$TERM" "$HOME/.dircolors.$TERM" \
      "$HOME/.dir_colors" "$HOME/.dircolors"; do
     -e "$colors" ] && COLORS="$colors" && break
  done

   -z "$COLORS" ] &&  -e "/etc/DIR_COLORS.256color" ] && \
       "x`tty -s && tput colors 2>/dev/null`" = "x256" ] && \
      COLORS="/etc/DIR_COLORS.256color"

  if  -z "$COLORS" ]; then
    for colors in "/etc/DIR_COLORS.$TERM" "/etc/DIR_COLORS" ; do
       -e "$colors" ] && COLORS="$colors" && break
    done
  fi

  # Existence of $COLORS already checked above.
   -n "$COLORS" ] || return

  eval "`dircolors --sh "$COLORS" 2>/dev/null`"
   -z "$LS_COLORS" ] && return
  grep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return
fi

alias ll='ls -l --color=auto' 2>/dev/null
alias l.='ls -d .* --color=auto' 2>/dev/null
alias ls='ls --color=auto' 2>/dev/null

I personally use different (system-wide) DIR_COLORS based on the type of terminal, but I’m still trying to figure out where I source these files (under openSUSE):

# find /etc -name "DIR_COLOR*"
/etc/DIR_COLORS.xterm-color
/etc/DIR_COLORS.orig
/etc/DIR_COLORS.rxvt-unicode
/etc/DIR_COLORS.rxvt
/etc/DIR_COLORS
/etc/DIR_COLORS.xterm
/etc/DIR_COLORS.rxvt-256color

Right know it looks like my /etc/bash.bashrc.local is sourcing a script which is actually missing on this system (my fault!):

# colored ls
if  -r /etc/profile.d/colorls.sh ] ; then
        . /etc/profile.d/colorls.sh
fi

I find the default reverse color for STICKY_OTHER_WRITABLE and OTHER_WRITABLE uggly too. :wink:

OK, I got it.
@missingunix,

Some people here get rewarded for their answers. And I’m going to reward you for question, because bringing this problem to my attention allowed me to find and fix a bug in my openSUSE installations. I had it working in 11.3 but, for some reason, the colorls.sh and colorls.csh scripts were missing in my 11.4. Now I found out that it was actually handled by /etc/profilde.d/ls.bash under openSUSE - which get sourced by /etc/bashrc:

test -s /etc/profile.d/ls.bash && . /etc/profile.d/ls.bash

Have a look at this file! Here’s what it does:

  if test -x /usr/bin/dircolors ; then
        #
        # set up the color-ls environment variables:
        #
        if test -f $HOME/.dir_colors ; then
	    eval "`/usr/bin/dircolors -b $HOME/.dir_colors`"
        elif test -f /etc/DIR_COLORS ; then
	    eval "`/usr/bin/dircolors -b /etc/DIR_COLORS`"
        fi
    fi

All you have to do is

  • copy /etc/DIR_COLOR to ~/.dir_colors
  • uncomment and set another color value to OTHER_WRITABLE
#OTHER_WRITABLE 34;42 	# dir that is other-writable (o+w) and not sticky

If you want them to be displayed in the same color as other directories, use:

OTHER_WRITABLE 01;37 

If you want them to appear in yellow, use

OTHER_WRITABLE 01;33 

or in blue:

OTHER_WRITABLE 01;34 

etc.

And yes, I’m really missing Unix too. :wink:

  • I prefer colorls.sh though, as it allows to use different colors (or underline) under different terminals, like in X or in console.

Hi please_try_again, thanks for info! That is how I currently use the /etc/DIR_COLORS; under ~/.dir_colors. After using the ‘OTHER_WRITABLE’ variable, the highlighting effect has been deactivated.

Thanks!!!