This is a work in progress, I will be... Full Story
By Manny Fernandez
January 9, 2020
Adding Color to Your macOS “ls” Output
I am big on having colors on my cli. It makes things very easy to identify when things are amiss. I have this on my SecureCRT implementation. Here is an easy way to show colors on your ls
output on your macOS.
Before
Here is the default way iTerm2 displays the output.
Command to Change
Shell out to your terminal.
vi ~/.bashrc
Once you edit the file, hit i
to enter the edit
mode.
add alias ls="ls -G"
After
As you can see below, the blue text is very difficult to read against my dark background.
Customization
Since that Dark Blue is unacceptable for my use, here is how to customize it.
For this, I will edit the
vi ~/.bash_profile
In there we will enter
export CLICOLOR=1 export LSCOLORS=GxFxCxDxBxegedabagaced
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
In my example, value LSCOLORS=GxFxCxDxBxegedabagaced, means directory = Gx (1st Position) set to (bold cyan foreground and default background). So Capital G = Bold Cyan and lowercase x = the default background
Outcome
So on this output, I moved to my Desktop
folder so we could see some files and some fake executable files.
- Directory colors are Cyan in bold
- We see standard files shown in white
- Files with the
x
attribute are shown in red.
Hope this helps
Recent posts
-
-
I have been playing with the free version of... Full Story
-
In my day job, I am on a lot... Full Story