Add some color to your ESXi shell

September 7th, 2011 by jason Leave a reply »

A few days ago I wrote a piece about Tech Support Mode in ESXi 5.0 for those who prefer to use it.  I’m going to compliment it a bit with a small trick which may appeal to your visual senses.  Since the dawn of ESX and ESXi, we’ve been working inside a Service Console and ESXi Shell respectively which defaults to an off-white foreground character set on a black background.  This can be changed in the following file using vi as the editor:

/etc/profile

By adding the line shown below, the default shell prompt can be modified.  For the purposes of this writing, the goal is not to change the prompt itself (although this is where you’d do it), but rather to change the color of the prompt.  Normally, only the color of the prompt would change and all text that followed would default back to the stock foreground color.  The trick is to modify the prompt so that the color-set sequence is modified, and is not closed – rather it is left open so that that the foreground color of the prompt bleeds into all of the text the follows it.  The mechanics behind it as well as common color codes are described here.  I like the color Cyan.

Snagit Capture

In the example above, I’ve added the following new line to /etc/profile:

PS1=’\[\e[1;96m\][\u@\h \W]\$\[\e[1;96m\] ‘

Bold High Intensity Cyan comes from the string 1;96m which you’ll see defined in two spots in the line which I added.  After saving /etc/profile and re-establishing the ESXi shell connection, the change takes effect:

Snagit Capture

I’m a little happier at the command line now and sometimes it is the little things that help get me through the day.

Advertisement

No comments

  1. Hi Jason,

    Another quicker thing to do is to change your terminal client display options, and much faster as it will translate the color codes directly in the color you want it to render directly. (and you will have much more choice).

    I usually also change the default font to a bigger/bolder font to cope with places with strong lights (sun, ect)

    This way will allow you to avoid doing this modification on each ESXi /*NIX host.

  2. jason says:

    I agree with you there Timo in the situation where remote SSH (ie. via PuTTY) is used. As I’m sure you noticed, PuTTY is what I used to grab the screenshots for the blog post. I do use remote SSH to access the ESXi Shell a fair amount, but I also access the ESXi Shell out of band (ie. via DRAC, iLO, etc.) as well as locally via crash cart or rack mount KVM.