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. Commented Sep 22, 2013 at 23:35
  • Try to run dircolors manually in a shell to see if the binary exists and is located in the $PATH. Commented Sep 22, 2013 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). Commented Sep 22, 2013 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? Commented Sep 23, 2013 at 2:55

4 Answers 4


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
  • 12
    GNU dircolors is provided as gdircolors by brew's coreutils package.
    – m8mble
    Commented Jul 7, 2019 at 8:25
  • For example, I am trying LS_COLORS=$LS_COLORS:'ex=1;30:ln=36' ; export LS_COLORS; ls but it won't change the coloring when I do ls
    – alper
    Commented Jul 18, 2020 at 10:58
  • @alper You need to pass an option to ls to make it use colors. This is typically done with an alias. Also note that LS_COLORS only influences GNU ls, not e.g. the native ls on macOS. Commented Jul 18, 2020 at 14:00
  • I am able to mak ls use colors in macOS, but I can't change the colors. e.g. binary files shown as red but I couldn't figure out the way to change their colors
    – alper
    Commented Jul 18, 2020 at 21:38
  • 1
    @alper MacOS ls uses a different environment variable than GNU ls. Read the man page. Commented Jul 19, 2020 at 8:53

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

  • adding export CLICOLOR=YES and setting LSCOLORS seems like not make any change on my end
    – alper
    Commented Jul 18, 2020 at 11:08

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:



You can install dircolors from Homebrew coreutils package:

 brew install coreutils

However, GNU coreutils are not included in the PATH by default. Edit your ~/.zshrc, ~/.bashrc and add:

  export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"

Now after starting a new shell session dircolors should work.

  • This confused me until now. I thought it would be a separate package. Nice to see that dircolors is considered core :) Commented Jan 22, 2023 at 8:22
  • It is because all of these tools are maintained by GNU Core Utils project gnu.org/software/coreutils - apple does not allow anything GPL with any of their system. Commented Jan 22, 2023 at 9:53

You must log in to answer this question.

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