41

I want it to have all the colors for syntax folders, etc... How can I do that?

3

5 Answers 5

39

My terminal colors

terminal color examples

how to do it

download theme

from here: http://media.tannern.com/tanner.terminal

import into Terminal

After installing SIMBL and the correct terminalcolors you can import my terminal theme from the Terminal Preferences window.

where to find the import option

other tweaks

Adding this to the file ~/.profile will make ls color it's output by default.

# Make ls use colors
export CLICOLOR=1
alias ls='ls -Fa'

Adding this will define colors as variables to make a prompt easier to edit.

# define colors
C_DEFAULT="\[\033[m\]"
C_WHITE="\[\033[1m\]"
C_BLACK="\[\033[30m\]"
C_RED="\[\033[31m\]"
C_GREEN="\[\033[32m\]"
C_YELLOW="\[\033[33m\]"
C_BLUE="\[\033[34m\]"
C_PURPLE="\[\033[35m\]"
C_CYAN="\[\033[36m\]"
C_LIGHTGRAY="\[\033[37m\]"
C_DARKGRAY="\[\033[1;30m\]"
C_LIGHTRED="\[\033[1;31m\]"
C_LIGHTGREEN="\[\033[1;32m\]"
C_LIGHTYELLOW="\[\033[1;33m\]"
C_LIGHTBLUE="\[\033[1;34m\]"
C_LIGHTPURPLE="\[\033[1;35m\]"
C_LIGHTCYAN="\[\033[1;36m\]"
C_BG_BLACK="\[\033[40m\]"
C_BG_RED="\[\033[41m\]"
C_BG_GREEN="\[\033[42m\]"
C_BG_YELLOW="\[\033[43m\]"
C_BG_BLUE="\[\033[44m\]"
C_BG_PURPLE="\[\033[45m\]"
C_BG_CYAN="\[\033[46m\]"
C_BG_LIGHTGRAY="\[\033[47m\]"

Adding this will give you a multi-line colored prompt.

# set your prompt
export PS1="\n$C_LIGHTGREEN\u$C_DARKGRAY@$C_BLUE\h $C_DARKGRAY: $C_LIGHTYELLOW\w\n$C_DARKGRAY\$$C_DEFAULT "

For a list of escape sequences to use in prompts check this article

6
  • The link supplied in your answer is gone. Commented Jul 25, 2014 at 14:23
  • 1
    I've since stopped using Apple's Terminal application in favor of iTerm2 ( iterm2.com ) I prefer it's split windows over tabs and it does not need any hacks to support correct coloring (although I haven't used Apple's Terminal in some time and it may no longer need the hack listed above)
    – rennat
    Commented Jul 28, 2014 at 16:29
  • Can I use this theme for gnome shell? If yes how can I do? Thanks a lot.
    – michele
    Commented Jun 13, 2015 at 9:38
  • @rennat The problem with posting links to blog posts is that they go away and are unreliable, please update this post with the instructions from your blog
    – tread
    Commented Sep 19, 2015 at 7:32
  • @surfer190 I removed the link to that guys blog post since it's no longer necessary to patch terminal for proper color support.
    – rennat
    Commented Sep 25, 2015 at 14:50
21

geekology.co.za has an informative blog post on how to do this, "Enabling Terminals directory and file color highlighting in Mac OS X". In case it gets moved or deleted, the basics are:

Add to your .bashrc or .profile:

export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

Save the file. Open a new terminal and use

ls
ls -l
ls -la
ls -lah

The rest of the article has info on what the colors do and how to change them (the letters you assign to LSCOLORS is what controls what colors you see).

3
  • 6
    +1 for not simply linking to the answer and including the core of it here. Commented Mar 8, 2011 at 19:45
  • Looks like the link is 404
    – Borealis
    Commented Jan 11, 2018 at 3:18
  • Here's a tool to help customize the scheme: https://geoff.greer.fm/lscolors/
    – mathandy
    Commented Feb 24, 2018 at 3:23
10

As of Mac OS X Lion 10.7, Terminal allows you to customize the sixteen ANSI colors and also supports the 256-color palette.

So, installing SIMBL or other extensions to get more colors is no longer necessary.

0
1

People may want to check out zsh + prezto. There's a nice guide here. zsh is already installed in OSX. Prezto just adds stuff to your shell. Activate the syntax-highlighting module, and go to town :)

3
  • Looks like the link to the guide is broken. Giving a 404 :( Commented Sep 21, 2016 at 20:11
  • @Eric Thanks, I fixed the link. Also see the follow-up article here
    – Valorum
    Commented Jan 24, 2017 at 21:05
  • just installed looks really nice and clean
    – xv70
    Commented Feb 20, 2020 at 19:20
0

Here is what I use in 2023 to get Ubuntu colors for ls (which was my biggest pain when switching to Mac terminal). Looks like the Ubuntu color scheme has changed since the post by @sorens above, as what that post suggests doesn't match what I have on Ubuntu at all.

Add this to your .bashrc or .bash_profile:

# Use default ls output on Ubuntu
alias ls='ls -Fa'

# Use Ubuntu coloring scheme (as close as it gets)
export CLICOLOR=1
export LSCOLORS=ExGxFxbaCxbabahbaDacec

I believe it's as close as it gets to Ubuntu. I compiled this manually, based on the original dircolors -b output from my Ubuntu (dircolors is the util used to generate coloring of various file/dir types there). I tested it for a while, but if you happen see any mismatches, please write a comment.

A couple of mismatches that I believe cannot be fixed on Mac:

  1. A couple of colors are not an exact match (orange background -> yellow as Mac's ls doesn't have orange, orange foreground -> red) but it looks almost the same on my computer.
  2. Unfortunately Mac's ls doesn't allow coloring of file types, so images, video, audio files and archives aren't colored as in Ubuntu. I see no way to distinguish those files in Mac ls. Which is a huge miss indeed.

References

This may be useful if you want to tweak the colors.

  1. My original dircolors -b output (I trimmed the big part with file extension coloring, as I don't believe it can be used on Mac). So that you can compare the differences if necessary and start from there. Not everything below has its match in LSCOLORS variable used on Mac, the latter is much simpler.

    LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:';

  2. Explanation of dircolors syntax: https://linuxhint.com/ls_colors_bash/

  3. A more detailed one: http://www.bigsoft.co.uk/blog/2008/04/11/configuring-ls_colors

You must log in to answer this question.

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