Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

(Preface: I'm brand new to Linux.)

Problem

I'm trying to change to colors of the file system in the bash shell. I've altered my .bashrc file according to:

http://ubuntuforums.org/showthread.php?t=41538.

But on rebooting the shell or sourcing the .bashrc I get the error message:

dircolors -b : command not found

What have I done wrong?

Set-Up and So Far

I'm running a fresh Ubuntu Server 13.04.

I've created a .dir_colors file in my home directory using:

dircolors -p > ~/.dircolors

I've then altered my .bashrc to look like this:

# enable color support of ls and also add handy aliases
    if [ "$TERM" != "dumb" ]; then
        [ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors"
        [ -e "$DIR_COLORS" ] || DIR_COLORS=""
        eval "`dircolors -b $DIR_COLORS`"
        alias ls='ls --color=auto'
        #alias dir='ls --color=auto --format=vertical'
        #alias vdir='ls --color=auto --format=long'
    fi    

I also have force_color_prompt enabled

EDIT: printout of <~/.bashrc grep dircolors | od -t x1

0000000 20 20 20 20 65 76 61 6c 20 22 27 64 69 72 63 6f
0000020 6c 6f 72 73 20 2d 62 20 24 44 49 52 5f 43 4f 4c
0000040 4f 52 53 27 22 0a
0000046

EDIT: printout of whereis dircolors

dircolors: /usr/bin/dircolors /usr/bin/X11/dircolors /usr/share/man/man1/dircolors.1.gz
share|improve this question
    
There's a syntax error of some kind in your .bashrc. Maybe a special character sneaked in here, but what you posted in your question looks right. Please post the output of <~/.bashrc grep dircolors | od -t x1 –  Gilles Oct 6 '13 at 20:48
    
What is the output of this command: whereis dircolors? –  Radu Rădeanu Oct 6 '13 at 20:56
    
Added both print outs. –  Dominic Woodman Oct 6 '13 at 21:05
    
Based on the od hex output you appear to have regular single quotes (0x27 = ') instead of backticks (0x60 = `) around the eval argument eval "`dircolors -b $DIR_COLORS`" –  steeldriver Oct 6 '13 at 21:34
    
@steeldriver Cheers that was spot on. Embarrassingly I was not aware there was a difference. –  Dominic Woodman Oct 7 '13 at 14:07
add comment

1 Answer 1

up vote 0 down vote accepted

My final set-up. I used this command to create the dircolors config file in my user directory.

dircolors -p > ~/.dircolors 

I then edited my .bashrc. The if condition was substantially different to my final if condition, I spotted the correct place by looking for:

# enable color support of ls and also add handy aliases

I then changed that section to:

# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
    [ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors"
    [ -e "$DIR_COLORS" ] || DIR_COLORS=""
    eval "`dircolors -b $DIR_COLORS`"
    alias ls='ls --color=auto'
    #alias dir='ls --color=auto --format=vertical'
    #alias vdir='ls --color=auto --format=long'
fi

The crucial piece I got wrong was I used single quotations ' instead of backticks (See @steeldriver comment, I can't get them to print out), in the following line.

    eval "`dircolors -b $DIR_COLORS`"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.