Syntax Highlighting bash terminal and vim in Mac OS X

So far I was not a huge Apple fan. However, recently I received a MacBook Pro(Amazing Huh!). In Mac OS X; your default terminal shell is bash. But the Terminal itself put a burden on me; Unlike it is in Ubuntu or Cent OS; the folders and files names...etc are not color coded ending up frustrating. 

Here is how I made it colorful :P

STEP 1: 
Open up your terminal. You can simply press [⌘Command]+[SpaceBar] to appear 'Spotlight Search' and type 'terminal' and hit enter.


type "cd ~" and hit enter.

This will change the current directory into your home directory.


type "vim .bash_profile".

This command will open ".bash_profile" in vim editor. vim is a CLI based text editor.


Hit [i] to enter into --INSERT-- mode. This will enable you to insert new characters into the document. If there '.bash_profile' is not existed before; 'vim' will create a new one for you and it will appear empty. Otherwise; make sure you are not changing other settings in the file.

After entering --INSERT-- mode; type the following;

export CLICOLOR=1

Enter [Esc] to exit from --INSERT-- mode. Then type ":wq" and hit enter.

":wq" -> will write and quite from the vim
":q!" -> will exit without saving your changes(If you did something wrong!)

In the terminal; enter "source .bash_profile".

This will apply configurations into the current bash shell. Or you can skip this step and re-open the terminals.

Now type "ls -l" you will experience it ! Enjoy !!!

If you need to highlight syntaxes in the vim editor as well; follow the same steps to edit the file. Simplest way is to create a file in '~/.vimrc'. 

So your command would be "vim ~/.vimrc" and enter the following;

filetype plugin indent on
syntax on


Rasika Perera

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment