Abner Ballardo

The out-of-the-box configuration of the Terminal application in Mac OS X is quite simple/plain. If you don’t use it frequently, it will be ok to leave it in that way. However, if you continuously open Terminal, it will be great to customize it so you can be more productive.

By default, this is how Terminal application looks like (Basic Profile):

As you can see, it is based just in black text and white background but you can give more life to Terminal using colors and this article will explain how to customize it according to your own tastes.

Mac OS X Terminal

First, let’s change the default profile to other one . To do so, open a new Terminal and go to Terminal -> Preferences -> Profiles. In my case, I like the Pro Profile (cool name!) because it looks like an old terminal with white text and black background.

Besides changing the profile, you should consider enabling the following options in Text Tab:

  • Antialiases text: To apply text smoothing. It is specially useful with some kind of monitors but you can leave it enabled any way.
  • Use bold fonts: To use bold for emphasis. Must be enabled.
  • Allow blinking text: To allow text to flash on and off. Highly recommended.
  • Display ANSI colors: To display text using the colors embedded in some terminal emulator standards. Must be enabled.
  • Use bright colors for bold text: To add emphasis to bold text with color. Must be enabled.

Configuring BASH

Now it is time to configure the BASH prompt; that means, change the environment variable $PS1. Let’s check its default value:

optimus:~ modlost$ echo $PS1
\h:\W \u\$

The prompt shows the hostname (\h), colon (:), current directory base name (\W), username (\u) and # or $ symbol ($). You can find more information about all the backslash-escape especial characters available for this variable in the unix man page for BASH section PROMPTING. In this case, we are going to use these options:

  • \u: The username of the current user.
  • \h: The hostname up to the first ‘.’.
  • \w: The current working directory, with $HOME abbreviated with a tilde.
  • $: If the effective UID is 0, a #, otherwise a $

In my experience a simple (short) prompt works best and Debian distribution defines one by default that I really like. Take a look at it executing the following command:

optimus:~ modlost$ PS1='\u@\h:\w\$ '

Looks great but it will be better with colors. To help you decide which color you would like, you can use this shell script to print the 16 ANSI color codes. Execute it in a Terminal using your prefered profile so you can decide which colors are best for you.

Now you can choose where you want to change colors coping those codes in $PS1. Debian distribution define a nice colors, let’s use the same:

modlost@optimus:~$ PS1=‘\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[m\]\$ ‘

To make these changes permanent you should define $PS1 in .bash_profile because Terminal starts login shells. At the end of the next section you will find a complete ~/.bash_profile.

Configuring ls and grep commands

If you use the Terminal a lot, it is probably that ls is one of your most used commands so adding color will be awesome. To do that, you will have to define a new enviroment variable LSCOLORS containing a string that has the following structure:

  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

Each one of those items contains two characters, one for the foreground and the other for the background. The color codes you can use are:

  • 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

For Pro Profile that uses dark background, this could be one good color combination:

modlost@optimus:~$ LSCOLORS=ExFxBxDxCxegedabagacad

But it doesn’t work unless you add the -G option in every ls execution, so the best way to do that is defining aliases:

modlost@optimus:~$ alias ls='ls -G'
modlost@optimus:~$ alias ll='ls -l'
modlost@optimus:~$ alias la='ls -A'
modlost@optimus:~$ alias l='ls -CF'

Execute them to test the configuration:

Another quite common command is grep and it also supports colors, you just need to define the following alises:

modlost@optimus:~$ alias grep='grep --colour=auto'
modlost@optimus:~$ alias fgrep='fgrep --colour=auto'
modlost@optimus:~$ alias egrep='egrep --colour=auto'

Execute a little example and you will see how useful is enabling colors in grep:

So the final ~/.bash_profile is the following:

export PS1="\[\e]0;\a\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[m\]\$ "

export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -G'
alias grep='grep --colour=auto'
alias fgrep='fgrep --colour=auto'
alias egrep='egrep --colour=auto'

alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'

Configuring Vim

Finally, if you use Vi Editor a lot, you should create a ~/.vimrc file with the following content:

syntax on
set background=dark

And the result will be the following:

Next Steps

Now your Mac OS X Terminal Application has a lot of colors and that will help you every day and make you more productive.

Happy Hacking!!!!

Abner Ballardo

The last week, I attended for the very first time the Wong parade (Corso de Wong), a quite popular parade here in Lima - Perú. That’s why, I grabbed my camera and took a few shots…

Abner Ballardo

A few months ago, I was discussing about social media in business with some friends, when someone asked me: “Why you don’t have a Facebook or Google+ page for your blog?”. My honest answer was: “Because of my laziness”. I know that creating a page is too simple but the real challenge is to maintain it with content, so I was thinking about it for a few weeks before I created them, just as proof of concept.


And at the end of the last year, the proof of concept ended with a plan: I can maintain it with content that I find in the web and don’t require a blog post or article, I’m an avid reader so I always have something to share. So I invited you to join my Facebook & Google+ pages; you will find Software Development, Music and Photography content.

Happy hacking!!!

Module Lost Google+ Page Removed

Module Lost Facebook page

Module Lost | Promote Your Page Too

Abner Ballardo

A new year has come and, for sure, you have a lot dreams or ideas around your head. Maybe you have them for years without doing anything to make them real, but the 2013 could be different. Watch these videos and let your heart beat and begin this year motivated to do something.

Happy hacking!!!!

Steve Jobs - Stanford

Neil Gaiman - University of Arts

Randy Pausch - Achieving your childhood dreams

Abner Ballardo

In this short talk, Renny Gleeson presents a different way to use the classic HTML 404 Error Page. He proposed to have friendlier messages in the web and also use them to capture users/clients interest.�It is something to consider in the next web projects, isn’t it?.

Finally, he left this quote that could be useful when you are defining an HTML 404 Error Page.

“A simple mistake can tell me what you aren’t. Or remind me why I love you”

Abner Ballardo

Over the last years, I’ve been interested in happiness because there is a lot of information that you can apply in your life, it is better to try something that works for others than starting from scratch. Furthermore, trying new things makes your life exciting because you learn new stuff about you. That’s why, I’m always looking for new information reading books, articles and papers; trying some ideas in my life and, sometimes, writing about what I found in my website.

This time, I’m going to share with you about the book The Power of Happiness: A Comprehensive Guide to Daily Joy and Well-Being by Timothy McKinney. In my opinion, it’s a great book with a lot of useful information that you can apply in your life. For sure, after reading it, you will end with a lot of next actions and things to try, like me.

The most important thing I learned from Timothy’s book is that life isn’t supposed to be easy (Chapter 11). It sounds simple but I’ve never thought of it that way. I used to assumed that I was unlucky when some events happened in my life but that’s not true. Life is not easy! So you can better enjoy the challenge of living assuming that it won’t be easy and also practicing non-attachment.

I also found a relationship with Pragmatic Thinking & Learning by Andy Hunt. Both agree that you can rewire your brain (Refactoring your wetware in Andy’s book). So if you want to be happier you should rewire your brain by changing your attitude and having happy thoughts. In such a way, your brain will rewire itself for happiness.

In conclusion, I highly recommend this book, it’s easy to read and you won’t stop because all the information is very interesting and useful for you life.

Haz click aquí para leer la versión en español