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.

 
STEP 2:

type "cd ~" and hit enter.

This will change the current directory into your home directory.

STEP 3:

type "vim .bash_profile".

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

STEP 4:

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

STEP 5:
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!)

STEP 6:
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.

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



BONUS:
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



SHARE

Rasika Perera

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