1

(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
5
  • 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 Oct 6, 2013 at 20:48
  • What is the output of this command: whereis dircolors? Oct 6, 2013 at 20:56
  • Added both print outs. Oct 6, 2013 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`" Oct 6, 2013 at 21:34
  • @steeldriver Cheers that was spot on. Embarrassingly I was not aware there was a difference. Oct 7, 2013 at 14:07

1 Answer 1

3

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`"

You must log in to answer this question.

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