7

I'd like to change the colors. The lime green hilighting on pale blue colored file names is killing my eyes.

I'm not sure if I'm using xterm or gnome or whatever, but I would like to change the default color scheme (preferable to something less offensive to my corneas) and have it stay changed (update my user profile).

Colors are nice, but sometimes it makes the text unreadable. I would settle for having no colors, standard B&W, if I can't have nice colors.

Josh K
  • 454
  • 1
  • 6
  • 18

3 Answers3

8

You'll need to configure your LS_COLORS export in your ~/.dir_colors (system wide at /etc/dir_colors)

See here for documentation: http://manpages.ubuntu.com/manpages/karmic/man5/dir_colors.5.html

::EDIT::

To make it stick:

  1. append this to your ~/.bashrc
    if [ "$TERM" != "dumb" ]; then
      [ -e "$HOME/.dir_colors" ] && 
      DIR_COLORS="$HOME/.dir_colors" [ -e "$DIR_COLORS" ] ||
      DIR_COLORS="" 
      eval "`dircolors -b $DIR_COLORS`" 
      alias ls='ls --color=auto'
    fi
  1. create/edit your ~/.dir_colors,

    for example with dircolors --print-database > .dir_colors

  2. Then force a read of your .bashrc file with:

    $: source ~/.bashrc

  3. Everything should be pretty.

towi
  • 103
  • 4
David Rickman
  • 3,320
  • 18
  • 16
  • How would I go about setting `~/,dir_colors` to be loaded on login? Is there any way to load a profile of colors? I can't match colors to save my life. – Josh K May 01 '10 at 05:21
  • See edit in comment. – David Rickman May 01 '10 at 07:16
  • According to the man page you linked to, those files are ignored by GNU dircolors. On Ubuntu, your `~/.bashrc` file should have a line like `eval "`dircolors -b`"`. You could try changing it to `eval "`dircolors -b ~/.dir_colors`" and create that file by doing `dircolors -p > ~/.dir_colors` then edit it to change particular file types. – Dennis Williamson May 01 '10 at 07:29
  • What files? .bashrc is your user-configurable bash shell. .dir_colors is your user configurable file for dircolors. Making it stick via the .bashrc file is going to be the only way to have it stick with every login unless you go global for everything. In which case, I don't want your pink directory colors. – David Rickman May 01 '10 at 08:59
  • "/etc/DIR_COLORS (Slackware, SuSE and RedHat only; ignored by GNU dircolors(1) and thus Debian.) System-wide configuration file." (it says the same thing for `~/.dir_colors`) However, your code above (and the code in my comment) takes care of this. – Dennis Williamson May 01 '10 at 12:05
  • 1
    What should I put in `~/.dir_colors`? – Josh K May 01 '10 at 14:59
  • @Dennis, ah, alright. I see now. – David Rickman May 02 '10 at 04:03
  • @Josh K: This link gives the exact directions I have for this with a few examples listed. See http://ubuntuforums.org/showthread.php?t=41538 – David Rickman May 02 '10 at 04:06
  • The "if file exists, then default..."-logic did not work for me. But One can specialize it to a simple `if [ "$TERM" != "dumb" ]; then eval $( dircolors -b $HOME/.dir_colors ) fi ` – towi Sep 10 '13 at 08:48
3

How to change the colors of file listings in Linux shells

Summary

Linux interactive terminals (aka ssh terminal, konsole or console login) automatically choose colors for 'files', 'directories', 'hard links', 'soft links', 'pipes', 'sockets', 'filesystems', etc. You see these colors displayed when you type 'ls' to list file contents. Directories are usually blue, files are usually light grey. Different foreground/background colors are used for various kinds of filesystem objects.

Problem:

Your terminal displays directory links as dark blue when you type 'ls', and you want it to be light cyan so you can read it better.

Solution

Using your favorite editor, open this file: /etc/DIR_COLORS You should see something like this:

#NORMAL 00      # no color code at all
#FILE 00        # regular file: use no color at all
RESET 0         # reset to "normal" color
DIR 01;34       # directory
LINK 01;36      # symbolic link.  (If you set this to 'target' instead of a
                # numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 00        # regular file with more than one link
FIFO 40;33      # pipe
SOCK 01;35      # socket
DOOR 01;35      # door
BLK 40;33;01    # block device driver
CHR 40;33;01    # character device driver
ORPHAN 01;05;37;41  # orphaned syminks
MISSING 01;05;37;41 # ... and the files they point to
SETUID 37;41    # file that is setuid (u+s)
SETGID 30;43    # file that is setgid (g+s)
CAPABILITY 30;41        # file with capability
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
STICKY 37;44    # dir with the sticky bit set (+t) and not other-writable

Notice the 4th line down starting with: "DIR". That is the color for your Directory links. If you want more info about what the codes mean visit this site:

http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html

Notice the code for DIR is '01;34'. the 34 means dark blue. You may be tempted to just edit this file /etc/DIR_COLORS right where it sits. DON'T do that. Because then you'll be changing the colors for EVERYONE who logs into this computer. You'll have to make a copy of this in your own directory so only your login is affected.

How to change the directory colors for your user

Copy /etc/DIR_COLORS into your home directory with this command:

cp /etc/DIR_COLORS /home/yourusername/.dir_colors

Open up your /home/yourusername/.dir_colors in your favorite editor and edit the line that looks like this:

DIR 01;34       # directory

And change it to this;

DIR 01;36       # directory

34 is the code for blue, 36 is the code for cyan. Save the /home/yourusername/.dir_colors You'll have to logout/login for the settings to take effect. (sourcing your profiles won't suck in the changes). Once you logout/login, run the command 'ls'. The directories should show up with cyan instead of blue. Like this:

Before:

enter image description here

After:

enter image description here

Eric Leschinski
  • 4,211
  • 4
  • 21
  • 27
0

Assuming you're using gnome-terminal, you can select Edit > Profiles... and select the profile that's current (e.g. Default) and click Edit (or click New and enter the name of a new profile - if you do this then you'll need to later set it as the "Profile used when launching a new terminal"). Now you can click on the Colors tab where you can set the background and foreground colors and manipulate the color palette (including selecting among built-in schemes).

You might try the White on black foreground/background scheme and the Tango palette (which has colors that are a bit muted).

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151