I just switched to a Macbook Air. I installed zsh using homebrew, but when I use some of the code that I (originally had) in my .zshrc, I get an error saying that .dircolors was not found.

Below is the code in question:

zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true

zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'

Is dircolors not shipped with Mac OS X? How should I install it?


If I run dircolors directly on the shell I get:

bash: dircolors; command not found

  • Are you sure that it's really this code that causes the error? Only the dircolors -b seems suspicious, but on my computer it works without a ~/.dircolors file just fine. – Martin von Wittich Sep 22 '13 at 23:35
  • Try to run dircolors manually in a shell to see if the binary exists and is located in the $PATH. – Martin von Wittich Sep 22 '13 at 23:36
  • Is the error really .dircolors was not found and not about dircolors? There is no dircolors command on OSX unless you installed it yourself, it's specific to Linux (or more accurately to GNU coreutils). – Gilles Sep 22 '13 at 23:38
  • Thanks @Gilles. When I type in the shell dircolors I get: bash: dircolors: command not found. The code I posted in the OP was automatically generated by Zsh on a Linux machine. I thought I could clone my .zshrc to my Mac OS X directly. Do you know what the code in my OP does or have any suggestions on how to modify it to bring the equivalent functionality to Mac OS X? – Amelio Vazquez-Reina Sep 23 '13 at 2:55

The command dircolors is specific to GNU coreutils, so you'll find it on non-embedded Linux and on Cygwin but not on other unix systems such as OSX. The generated settings in your .zshrc aren't portable to OSX.

Since you're using the default colors, you can pass an empty string to the list-colors to get colors in file completions.

For colors with the actual ls command, set the CLICOLOR environment variable on OSX, and also set LSCOLORS (see the manual for the format) if you want to change the colors.

if whence dircolors >/dev/null; then
  eval "$(dircolors -b)"
  zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
  alias ls='ls --color'
  export CLICOLOR=1
  zstyle ':completion:*:default' list-colors ''

If you wanted to set non-default colors (dircolors with a file argument), my recommendation would be to hard-code the output of dircolors -b ~/.dircolors in your .zshrc and use these settings for both zsh and GNU ls.

zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
if whence dircolors >/dev/null; then
  export LS_COLORS
  alias ls='ls --color'
  export CLICOLOR=1
  • 2
    GNU dircolors is provided as gdircolors by brew's coreutils package. – m8mble Jul 7 at 8:25

Since FreeBSD has no command dircolor and OS X has the base of FreeBSD you can't use it.

The simplest thing is to use


in your .zshrc and .bashrc and remove eval "$(dircolors -b)". To change the colors you can use the environment variable LSCOLORS. For example:

export LSCOLORS="Gxfxcxdxbxegedabagacad"

You can find out more about it in the man page with

man ls

An alternative to export CLICOLOR=YES is to use an alias for ls

alias ls=ls -G

Some suggested to install the GNU-Coreutils from Mac Ports, but in my opinion this is an overkill. You can find the port here


I don't do the whole mac thing anymore, so I don't have anything to test with, but in the quest to get this working on FreeBSD, I managed to figure out how to get this working from ports. I recall OSX has stuff like brew and macports - Try installing the GNU coreutils from this if you really want dircolors to work. I also had to set an alias for dircolors to gdircolors as this is the command that FreeBSD ports installed the fun as. Good luck to anyone who ends up trying this out!

Here's a link to someone getting the coreutils down via brew:


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.