Mac Terminal Colors for List Command: ls

January 23, 2013 — 6 Comments

A guide to customizing colors in Mac OS X Terminal for the command ls. Performed on OS X Lion.

Purpose: To easily distinguish between directories and files.

Example: See Step 1. You may choose a different set of element colors.

Note: My current Terminal – Preferences are set to {Theme: Basic, Font: Menlo, Font Color: Yellow, Font Size: 16}

Detailed Video:

1. List dot files in your home directory

11.png

 

Execute commands:

$ cd ~
$ ls -ld .*

2. Locate .profile File

If .profile does not exist, look for .bash_profile and use instead.

See this reference for more information.

3. Open .profile

Execute command:

open .profile

4. Edit .profile

wpid269-4._Edit_.png

 

Add the following lines:

export CLICOLOR=1
export LSCOLORS=exfxcxdxbxegedabagacad

For more information on how to configure the second line, see the LSCOLORS section of the list command man page:

$ man ls

If you want emulate my settings exactly then use this as the value of LSCOLORS:

hxfxcxdxbxhghdabagacad

5. Save File and Open New Terminal Window

Upon saving the .bash_profile file, you will need to open a new terminal window to see the changes. Experiment and enjoy!

Related References:

Helpful site for auto generating ls colors. Use the BSD style is your using a Mac:

Jay

Posts

6 responses to Mac Terminal Colors for List Command: ls

  1. Thanks for sharing the important information with us.

  2. I do not have bash_profile
    I hava bash_history, Is it OK?

  3. Hi Jay,

    Not really sure why it isn’t opening up the .bash_profile file, I keep getting this message:

    Last login: Fri Nov 21 03:24:22 on ttys000
    /Users/vtv/.bash_profile ; exit;
    VTVs-MBP-2:~ vtv$ /Users/vtv/.bash_profile ; exit;
    logout

    [Process completed]

    Any suggestions?

    Thanks,
    Vinh

    • Hi Vinh,

      Thanks for your question. Unfortunately I didn’t notice comment notification until now. For most technical questions I like to direct readers to Stack Overflow, where you can receive better support from many knowledgable folks to benefit from group intelligence.

      However, you might also benefit from reviewing another webapphero article which goes over my setup of bash startup files in general: http://www.webapphero.org/configuring-bash-startup-files-on-os-x

      If you do (or already have) started a Stack Overflow thread, please consider linking to it from a new comment below. Good luck Vinh and thanks for reading my blog!

      My best,
      Jay

I welcome your comments