5

I'd like to customize the colors of ls and as far as I understand the way to go is with dircolors.

I did:

dircolors > ~/.dircolors

Immediately after this I launch a terminal and get this error:

dircolors: /home/frank/.dircolors:1: invalid line;  missing second token

I have not changed anything in ~/.dircolors. Running Ubuntu 11.10 x64. The file looks like this.

    LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00: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:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=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:*.svgz=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:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=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:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:';
export LS_COLORS
8

You can try

dircolors -p >.dircolors

It also can solve the problem

1
  • This is likely the only correct answer in this thread.
    – doctorG
    Jan 15 '17 at 15:03
4

I had the same problem under Ubuntu 12.04. The solution was to edit the ~/.dircolors file to remove the second line ('export LS_COLORS') and make the first line do the export:

export LS_COLORS='...

No, I have no idea why.

1
  • This is the answer, though don't know why.
    – Honghe.Wu
    Feb 22 '17 at 12:56
3

Looks like you're using csh.

Try:

dircolors -c > ~/.dircolors

(Note: some setups use .dir_colors instead.)

3

Preliminary assumption/expectation: the OP is somewhere running the command

dircolors /home/frank/.dircolors

probably in a bash config file as

eval "$(dircolors ~/.dircolors)"

From the man page for dircolors:

SYNOPSIS dircolors [OPTION]... [FILE]

and

If FILE is specified, read 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'.

In other words, if you give dircolors a file argument, it expects a file format as given by 'dircolors -p'. Any other format will not work as intended as you are then getting the output of dircolors as intended for updating environment variables in shells. Deleting that second, "export", line may stop the error but the result will not be what you expect if you ever try to edit your dircolors database file.

The accepted answer by Mat likely was also the first answer that stopped the error message. But will not be doing what you hope!

2

what I found the solution was:- first of all check whether you have ~/.dircolors file or not? if not then put this in your terminal:-

dircolors -p > ~/.dircolors

then open your zshrc file from any text editor you want for eg using sublilme:-

subl ~/.zshrc

and add these lines into that file:-

eval "$(dircolors ~/.dircolors)"
alias dir='dir --color'
alias ls='ls --color=auto'

now you have got your solution done. if you want to change the colors open .dircolors through your editor and change the value of the color and other stuffs. go to this link for the colors : - http://linux-sxs.org/housekeeping/lscolors.html

Solution of other did not work for me. Perhaps because I am using zsh shell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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