14

I use putty with a black background and was wondering if there was or is a way to change the colors of the dirs which are dark blue.

i noticed DIR_COLORS.xterm and DIR_COLORS

do they play this role?

4 Answers 4

10

It depends on the version of Linux your using, for example on Ubuntu you edit the Bash File while on others you edit the DIR_COLORS.

CentOS/RHEL/Fedora

Step 1 - Copy the DIR_COLORS to your home folder or skip this for all accounts.

cp /etc/DIR_COLORS ~/.dir_colors

Step 2 - Edit the DIR_COLORS (If you copied it to your home folder, otherwise just vi dir_colors

vi ~/.dir_colors

Step 3 - Find

DIR 01;34     # directory

Step 4 - Replace with (Change the 33 with the color you want)

DIR 01;33     # directory

You may need to do this in the Xterm file as well, but generally that is more local.

Ubuntu

Step 1 - Ubuntu Backup the Bash File First

sudo cp .bashrc .bashrc-backup

Step 2 - Then nano the Bashrc File

sudo nano .bashrc

More help for Ubuntu users can be found here.

http://help.ubuntu.com/community/CustomizingBashPrompt

1
  • 5
    For Ubuntu, you shouldn't use sudo to edit your own .bashrc. That said, the guide you linked just covers colorizing the prompt, not ls. It appears that Debian-type distros don't use ~/.dir_colors for ls, they use the $LS_COLORS environment variable which can be setup with a little program called dircolors
    – DerfK
    Jan 7, 2013 at 20:18
11

PuTTY uses its own colour specs for emulating X terminals. It is under the Window -> Colours category in the main configuration window you get on startup. In the section 'Adjust the precise colours PuTTY displays' you can edit entries in the 'Select a colour to adjust' box. The usual directory colour, for example, is ANSI blue. I find this too dark, so I lighten it to (74,74,255).

To enable colours in a standard bash session under most distros (and certainly Debian-like things such as Ubuntu,) first test for the existence of the dircolors executable, then look for a local override .dircolors. If found, run dircolors with the local file and if not use the system defaults.

if [ -x /usr/bin/dircolors ]; then
   test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
fi

The -b flag means emit Bourne shell compatible colourisation rules. To alter the colours themselves, you will need to provide an X11 resource file with the overrides you want. Put this in ~/.Xresources and add lines like *xterm*color12: #1e90ff. This will get merged into your X resource database on next login. You will need to experiment to see which colour gets mapped to which file type.

0
3

You can modify .dircolors.xterm, for instance, using the following codes... In your case, if you want a different directory color, change from "01;34" to something like "01;31".

# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 00       # global default, although everything should be something.
FILE 00         # normal file
DIR 01;34       # directory
LINK 01;36      # symbolic link
FIFO 40;33      # pipe
SOCK 01;35      # socket
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
1

I had the same issue using PuTTY on Windows to connect to a linux box. A quick fix is to use the Saved Session feature of the PuTTY UI. From the PuTTY startup screen:

  1. Open the "Session" tab: Enter a session name in the "Saved Sessions" text box
  2. Open the "Window" > "Colours" tab: under the "Select a colour to adjust" select box, choose "ANSI Blue". Click the "Modify" button.
  3. Select a lighter color.
  4. Open the "Session" tab: make sure your new session is selected and click the "Save" button

Now, when you want to connect again, you can select your Saved Session and Load it. Your colors will be preserved.

If you are connecting to the same box repeatedly, I prefer the other answers. I would rather edit a config file than use the UI. However, I have found this useful when I need to connect to a new machine only a few times.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .