Results 1 to 8 of 8

Thread: DIR_COLORS

  1. #1
    Join Date
    May 2010
    Location
    East Bay, CA
    Posts
    32

    Smile 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?

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: DIR_COLORS

    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.

  3. #3
    Join Date
    May 2010
    Location
    East Bay, CA
    Posts
    32

    Default Re: DIR_COLORS

    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.

  4. #4
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: DIR_COLORS

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

    Code:
    DIR    01;34    # directory

  5. #5

    Default Re: DIR_COLORS

    Quote Originally Posted by ken_yap View Post
    DIR_COLORS? This is not DOS.
    No!
    Code:
    rpm -qf /etc/DIR_COLORS
    aaa_base-extras-11.4-54.68.1.x86_64
    Quote Originally Posted by ken_yap View Post
    Also it has nothing to do with the directory, it's a global setting.
    Not really.


    Quote Originally Posted by missingunix View Post
    But, /etc/DIR_COLORS modifies the behaviour of the LS_OPTIONS?
    No, it rewrites LS_COLORS. See:
    Code:
    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.

  6. #6

    Default Re: DIR_COLORS

    Fedora provides /etc/profile.d/colorls.sh and /etc/profile.d/colorls.csh in coreutils. Here's how colorls looks like:
    Code:
    # 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):

    Code:
    # 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!):

    Code:
    # 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.

  7. #7

    Default Re: DIR_COLORS

    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:

    Code:
    test -s /etc/profile.d/ls.bash && . /etc/profile.d/ls.bash
    Have a look at this file! Here's what it does:

    Code:
      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
      Code:
      #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:
      Code:
      OTHER_WRITABLE 01;37
      If you want them to appear in yellow, use
      Code:
      OTHER_WRITABLE 01;33
      or in blue:
      Code:
      OTHER_WRITABLE 01;34
      etc.



    And yes, I'm really missing Unix too.

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

  8. #8
    Join Date
    May 2010
    Location
    East Bay, CA
    Posts
    32

    Default Re: DIR_COLORS

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •