Announcement

Collapse
No announcement yet.

Kubuntu dircolours

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Kubuntu dircolours

    I've figured out how to edit the .bashrc file to change the colour of my prompt, but how to change the colour of the ls output appears beyond me. The net has lots of convoluted advice which does not apply to Kubuntu and none tell me what file to edit! All I want to do is change the colour of a couple of file types. The output of "dircolors -p" is clear, but I can't find the file.

    In short, how do I change .jpg from 01;31 to 01;37?

    #2
    Re: Kubuntu dircolours

    Originally posted by man ls
    The environment variable LS_COL‐
    ORS can influence the colors, and can be set easily by the dircolors command.
    IOW we need to look at dircolors and $LS_COLORS.

    Originally posted by info coreutils 'dircolors'
    10.4 `dircolors': Color setup for `ls'
    ======================================

    `dircolors' outputs a sequence of shell commands to set up the terminal
    for color output from `ls' (and `dir', etc.). Typical usage:

    eval "`dircolors [OPTION]... [FILE]`"

    If FILE is specified, `dircolors' reads it to determine which colors
    to use for which file types and extensions. Otherwise, a precompiled
    database is used. For details on the format of these files, run
    `dircolors --print-database'.

    The output is a shell command to set the `LS_COLORS' environment
    variable. You can specify the shell syntax to use on the command line,
    or `dircolors' will guess it from the value of the `SHELL' environment
    variable.
    Hmm.

    Code:
    $ echo $LS_COLORS
    no=00:fi=00: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:*.svgz=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:*.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:*.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:
    So it looks like you need to change the LS_COLORS environment variable, not a file. The dircolors command looks like a simple frontend program for doing just that.

    HTH
    Welcome newbies!
    Verify the ISO
    Kubuntu's documentation

    Comment


      #3
      Re: Kubuntu dircolours

      Thanks Telengard. Ya, I got that far - I just didn't believe that they would make something that common such a learning curve. I looked in Kubuntu System Settings and there's nothing there. Strange.

      I guess this is the time I learn about environmental variables in Linux.

      Is "export" in Linux the same as "set" in DOS?

      Comment


        #4
        Re: Kubuntu dircolours

        May I suggest that you get your self a copy of "Learning the bash Shell" Second Edition (or newer) published by O'Reilly. This will serve you well - I have it among the several 'Linux' books next to my PC.
        Windows no longer obstructs my view.
        Using Kubuntu Linux since March 23, 2007.
        "It is a capital mistake to theorize before one has data." - Sherlock Holmes

        Comment


          #5
          Re: Kubuntu dircolours

          Originally posted by Ole Juul
          Is "export" in Linux the same as "set" in DOS?
          Not quite. Environment variables in DOS are global. Environment variables in Linux are local until you export them.

          Originally posted by The GNU Bash Reference Manual
          3.7.4 Environment
          -----------------

          When a program is invoked it is given an array of strings called the
          ENVIRONMENT. This is a list of name-value pairs, of the form
          `name=value'.

          Bash provides several ways to manipulate the environment. On
          invocation, the shell scans its own environment and creates a parameter
          for each name found, automatically marking it for EXPORT to child
          processes. Executed commands inherit the environment. The `export'
          and `declare -x' commands allow parameters and functions to be added to
          and deleted from the environment. If the value of a parameter in the
          environment is modified, the new value becomes part of the environment,
          replacing the old. The environment inherited by any executed command
          consists of the shell's initial environment, whose values may be
          modified in the shell, less any pairs removed by the `unset' and
          `export -n' commands, plus any additions via the `export' and `declare
          -x' commands.
          If you have an environment variable you want to persist across Bash sessions then you can probably export it from within ~/.profile. The usual advice is to logout and login to force Bash to re-read ~/.profile, but in this case you can probably just set the variable, edit ~/.profile, and be done with it.

          Edit:

          Code:
          $ myvariable=myvalue
          export myvariable
          Then edit ~/.profile.
          Welcome newbies!
          Verify the ISO
          Kubuntu's documentation

          Comment


            #6
            Re: Kubuntu dircolours

            First: Thanks Snowdog for the bashbook recommendation. That is probably a good idea.

            Second: Thanks Telengard for the little lesson on environment. I'll read that twice.

            Third: I found it! The dircolor solution I mean ... Boy, that took a lot Googling. If their servers were temporarily overloaded, I apologize, it was my fault.

            1/ Edit the .bashrc file:
            Find the section starting with the line "# enable color support of ls and also add handy aliases" and delete line three and add three new ones. That section will look like this when you're finished. (Minus the <new tags!)
            Code:
            # enable color support of ls and also add handy aliases
            if [ "$TERM" != "dumb" ]; then
              [ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors" <new
              [ -e "$DIR_COLORS" ] || DIR_COLORS=""           <new
              eval "`dircolors -b $DIR_COLORS`"             <new
              alias ls='ls --color=auto'
              #alias dir='ls --color=auto --format=vertical'
              #alias vdir='ls --color=auto --format=long'
            fi
            2. Then issue the "dircolor -p" command and put the output in a file called ".dircolors". Do this from your home directory so the file will reside there. Like this:
            Code:
            dircolor -p > .dircolors
            3. Edit colours in ".dircolors" to your heart's desire! The instructions are in the file.

            4. Phew!

            Comment


              #7
              Re: Kubuntu dircolours

              Originally posted by Ole Juul
              First: Thanks Snowdog for the bashbook recommendation. That is probably a good idea.
              Im sorry he is SNOWHOG not SNOWDOG

              Comment


                #8
                Re: Kubuntu dircolours

                Originally posted by mariappan
                Originally posted by Ole Juul
                First: Thanks Snowdog for the bashbook recommendation. That is probably a good idea.
                Im sorry he is SNOWHOG not SNOWDOG
                Sorry Snowhog. I know that - I just type too fast - and you living in the land of the mushing and all. How's biking these days?

                Comment


                  #9
                  Re: Kubuntu dircolours

                  Snowdog? Where is By-tor?
                  Welcome newbies!
                  Verify the ISO
                  Kubuntu's documentation

                  Comment


                    #10
                    Re: Kubuntu dircolours

                    Originally posted by Ole Juul
                    How's biking these days?
                    All in my mind! Riding season here, 'officially' begins April 1st. It's come earlier, and it's come later.
                    Windows no longer obstructs my view.
                    Using Kubuntu Linux since March 23, 2007.
                    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                    Comment

                    Working...
                    X