11

I am using Prezto + zsh as my shell. I would like to change the color of directories when I ls my directory. For instance, here is what I currently have:

My crappy ls listing

Obviously, this is no fun, as I’m hardly able to read my directories because the blue is so dark. I’d like to change it to white or orange or something lighter.

This dark blue is specific only to directories. Files show up in a nice white text. Where and what settings must I find to change this?

4ae1e1
  • 7,228
  • 8
  • 44
  • 77
Cole Bittel
  • 2,646
  • 5
  • 18
  • 31

4 Answers4

24

Update

I've seen this answer still getting attention, so here's an update. Instead of messing with individual colours as below, simply adjust the Minimum Contrast within Preferences ... -> Profiles -> Colors. I set mine to 60.

enter image description here

Original answer

The easier way to do this is to change the colour scheme of your terminal. For example if you are using iTerm2 on a Mac then:

  • Launch iTerm2
  • type CMD+i
  • In the "Colors" tab, change the setting for "Blue" (and potentially the "Bright" equivalient)
  • In the "General" tab, click "Copy Current Settings to Selected Profile"

If you want to revert back to the defaults you can always select a value from the "Color presets..." dropdown in the "Colors" tab.

Do the equivalent in your favourite terminal if you don't use iTerm2 on a Mac.

Matt Byrne
  • 4,908
  • 3
  • 35
  • 52
2

The answer depends on your ls. BSD ls uses the environment variable LSCOLORS; coreutils ls uses LS_COLORS instead. See your man page.

The utility module of Prezto uses dircolors (if available) to customize the colors of coreutils ls, which also comes with coreutils. So if you have coreutils, then you can use dircolors to provide actually human-readable color definitions. Read the man page of dircolors for details. Prezto reads from $HOME/.dir_colors by default, otherwise it just use the default colors defined by dircolors. You can of course specify other locations by editing on top of Prezto.

For BSD ls, there's probably no utility comparable to dircolors, so one has to manually define LSCOLORS. See the ENVIRONMENT section of the man page on its format, which should be pretty clear. An example is LSCOLORS='exfxcxdxbxGxDxabagacad', used by Prezto by default. To have it take effect, put it in runcoms, after loading Prezto's utility module.

4ae1e1
  • 7,228
  • 8
  • 44
  • 77
  • Do you mean that if I just specify `dircolors` at the bottom of my .zshrc file, I can change this color? And if so, what would that `dircolors` look like? – Cole Bittel Oct 17 '15 at 21:39
  • `dircolors` is a command. What's your OS? And do you have coreutils installed? – 4ae1e1 Oct 17 '15 at 21:39
  • I'm on a MacBook with El Capitan. I don't see coreutils in `/usr/libexec/` so I don't believe so. – Cole Bittel Oct 17 '15 at 21:42
  • 1
    Well, `coreutils` is a package... But if you don't know what it is, chances are you don't have it. – 4ae1e1 Oct 17 '15 at 21:43
  • 1
    I would seriously recommend [coreutils](https://www.gnu.org/software/coreutils/coreutils.html) though. On OS X you can easily install `coreutils` with `brew install coreutils` (requires Homebrew, obviously), then putting coreutils' libexec before `/usr/bin` in your `PATH`. I don't want to get into religious conflicts, but after you use coreutils for a while, you'll find BSD utilities shipped with OS X like crippled cousins. Seriously. – 4ae1e1 Oct 17 '15 at 21:51
  • Would it matter which file in runcoms? I was thinking zshrc but don't have much reasoning for that. – Cole Bittel Oct 17 '15 at 21:59
  • Read `man zsh`, `STARTUP/SHUTDOWN FILES` section. It clearly indicates which file is for what. Here you want ls to show colors only in an interactive shell, and it doesn't matter whether it's a login shell or not, so it should go into `zshrc`. – 4ae1e1 Oct 17 '15 at 22:01
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/92663/discussion-between-cole-bittel-and-4ae1e1). – Cole Bittel Oct 18 '15 at 20:00
0

I may be late to the party but I found the answer here: https://github.com/sorin-ionescu/prezto/issues/1539

Run in the Terminal or add to your .zshrc file

export LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd"

eleove
  • 43
  • 6
0

Only adding this comment in case someone reads this thread in the future.

eleov eleove's answer, while correct, is missing a line before the export LSCOLORS="..." command. You must also include:

export CLICOLOR=1

source: https://infosecmonkey.com/adding-color-to-your-macos-ls-output/

Tyler2P
  • 2,324
  • 26
  • 22
  • 31