Faculty of Engineering and Mathematical Sciences 
Not logged in (login)


This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting (CITS4407).
RSS cloud
Jump to:

iTerm2 - Auto Coloring

1 of 390 articles shown, currently no other people reading this forum.
From: Christopher M.
Date: Wed 6th May 2020, 4:59pm


"David Tang" <22*7*2*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> Hi Chris,
> In the 23/4/2020 lecture recording, I noticed that you were using iTerm2 on MacOSX and 
> managed to get it to recognise and automatically colour variables, commands, strings etc 
> for easy readability by either:
> 1. adding this shebang to the header: #!/bin/bash. or
> 2. adding the .sh extension to a shell file
> I haven't managed to replicate this sucessfully.
> Where am I going wrong? Can you please provide further instruction?

Hello David,

What you're describing is not directly related to iTerm2 or macOS, but to configuring the
vim editor to recognise and colour code from common programming languages
(and works on Linux, too).

Firstly, see if you already have a .vimrc file :

  ls -l ~/.vimrc

If you don't we're going to create/give you one; if you do have one we need to append to it.
Download the file:


(should be 2513 bytes long), and then execute:

  cat vim-colours >> ~/.vimrc

to create or append to the file.

The next time you run vi or vim, it should show coloured code.


Related articles

iTerm2 - Auto Coloring (all 5) RSS
├─ original   Wed 6th May 2020, 2:32pm, David T.
├─ THIS   Wed 6th May 2020, 4:59pm, Christopher M.
├─ reply 2   Sat 9th May 2020, 2:24pm, David T.  O.P.
├─ reply 3   Mon 11th May 2020, 4:04pm, David T.  O.P.
└─ reply 4   Mon 11th May 2020, 5:06pm, Christopher M.
This Page

Program written by: [email protected]
Feedback welcome
Last modified: 11:27am Sep 21 2020