Results 1 to 8 of 8
  1. #1
    Color "ls" Output in Terminal
    mac57's Avatar
    Member Since
    Apr 29, 2006
    Location
    St. Somewhere
    Posts
    4,560
    Specs:
    iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM
    Color "ls" Output in Terminal
    Just a quick note to folks with a *nix background who may be using Terminal.app and are frustrated by the lack of color coding on the output. The BSD version of ls, which Mac OS X uses, is a bit different from the Linux versions most of us will be familiar with, and the usual /etc solutions don't work.

    To get color output (directories in blue, executables in red, and so on), add the following alias to your .bash_profile:

    Code:
    alias ls="ls -FG"
    The "F" part causes it to add slashes to the directories it lists, and the "G" part enables the color coding per the above.

    ...and who said the command line wasn't obvious?? :dive:
    My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
    My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
    My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
    I was on the Mac-Forums honor roll for September 2007

  2. #2
    Color "ls" Output in Terminal
    cradom's Avatar
    Member Since
    Feb 14, 2004
    Location
    Nederland, Texas
    Posts
    4,072
    Specs:
    13in macbook - 10.10.4
    Or, you can add the following to your .bashrc file:


    export CLICOLOR='true'
    export LSCOLORS="gxfxcxdxbxegedabagacad"

    My LSCOLORS= changes a couple of colors which were hard to see on my black background. You dont necessarily have to add that part.
    Always more than one way to do something.

    Edit: just noticed my ls alias has a g in it too:
    alias l='ls -lagh'
    try both.
    Craig Domingue
    (\__/)
    (='.'=) This is Bunny. Copy and paste Bunny into your
    (")_(") signature to help him gain world domination

  3. #3
    Color "ls" Output in Terminal
    mac57's Avatar
    Member Since
    Apr 29, 2006
    Location
    St. Somewhere
    Posts
    4,560
    Specs:
    iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM
    Thanks cradom. Can you break down the "alphabet soup" in the LSCOLORS var and explain the parts? Thanks!
    My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
    My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
    My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
    I was on the Mac-Forums honor roll for September 2007

  4. #4
    Color "ls" Output in Terminal
    cazabam's Avatar
    Member Since
    Jun 06, 2006
    Posts
    1,153
    Specs:
    MacBook 2.0GHz White, 512MB RAM, 60GB HDD
    You can find out more about LSCOLORS (and all the other environment variables ls reads) by typing:

    man ls

    You can search within the page by pressing / then typing the search.

  5. #5
    Color "ls" Output in Terminal
    cradom's Avatar
    Member Since
    Feb 14, 2004
    Location
    Nederland, Texas
    Posts
    4,072
    Specs:
    13in macbook - 10.10.4
    Straight from "man ls":

    The value of this variable describes what color to use
    for which attribute when colors are enabled with
    CLICOLOR. This string is a concatenation of pairs of the
    format fb, where f is the foreground color and b is the
    background color.

    The color designators are as follows:

    a black
    b red
    c green
    d brown
    e blue
    f magenta
    g cyan
    h light grey
    A bold black, usually shows up as dark grey
    B bold red
    C bold green
    D bold brown, usually shows up as yellow
    E bold blue
    F bold magenta
    G bold cyan
    H bold light grey; looks like bright white
    x default foreground or background

    Note that the above are standard ANSI colors. The actual
    display may differ depending on the color capabilities of
    the terminal in use.

    The order of the attributes are as follows:

    1. directory
    2. symbolic link
    3. socket
    4. pipe
    5. executable
    6. block special
    7. character special
    8. executable with setuid bit set
    9. executable with setgid bit set
    10. directory writable to others, with sticky bit
    11. directory writable to others, without sticky
    bit

    The default is "exfxcxdxbxegedabagacad", i.e. blue fore-
    ground and default background for regular directories,
    black foreground and red background for setuid executa-
    bles, etc.
    Craig Domingue
    (\__/)
    (='.'=) This is Bunny. Copy and paste Bunny into your
    (")_(") signature to help him gain world domination

  6. #6
    Color "ls" Output in Terminal
    mac57's Avatar
    Member Since
    Apr 29, 2006
    Location
    St. Somewhere
    Posts
    4,560
    Specs:
    iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM
    Thanks cradom - I should have thought of that!

    Tried to give you rep, but it said I had to spread some more around...

    oh well, virtual rep!!! Thanks again.
    My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
    My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
    My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
    I was on the Mac-Forums honor roll for September 2007

  7. #7
    Color "ls" Output in Terminal
    cradom's Avatar
    Member Since
    Feb 14, 2004
    Location
    Nederland, Texas
    Posts
    4,072
    Specs:
    13in macbook - 10.10.4
    If you really want color, go here:
    http://www.dotfiles.com/index.php?app_id=3
    Scroll down and get bash_styles. Color prompts and more!
    Lots of good stuff there.
    Craig Domingue
    (\__/)
    (='.'=) This is Bunny. Copy and paste Bunny into your
    (")_(") signature to help him gain world domination

  8. #8
    Color "ls" Output in Terminal
    mac57's Avatar
    Member Since
    Apr 29, 2006
    Location
    St. Somewhere
    Posts
    4,560
    Specs:
    iMac 27" 3.4 GHz, 256 GB SSD, 2 TB HDD, 8 GB RAM
    Thanks cradom!
    My Macs: iMac 27" 3.4 GHz, Mac Pro 3.2 GHz, PowerMac G5 Quad 2.5 GHz, G4 Cube with 1.2 GHz Upgrade
    My iStuff: 64GB iPhone 5, 64GB iPad4, 30GB iPod Video, 16GB iPod Touch
    My OS': Mac OS X Lion, Mac OS X Snow Leopard, Mac OS X Tiger, Mac OS 9.2.2, openSUSE 10.3
    I was on the Mac-Forums honor roll for September 2007

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Mac Mini 2014 - "SNOW" - grafical output troubles
    By Wimpi82 in forum Apple Desktops
    Replies: 5
    Last Post: 01-09-2015, 09:48 PM
  2. Replies: 1
    Last Post: 04-06-2013, 04:13 AM
  3. I thought I was supposed to have a "Line Out" audio output option on my MBP
    By VegasGeorge in forum Music, Audio, and Podcasting
    Replies: 2
    Last Post: 11-21-2009, 11:48 PM
  4. Replies: 5
    Last Post: 04-01-2009, 03:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •