Command prompt colours


Here’s an old trick which works great on ESX servers (thanks to this article on Linux Journal for reminding me).  It turns your prompt different colours to highlight when you are logged in as root.

To make the prompt red when you’re running as root add this to /root/.bashrc:

PS1=’\[\e[31m\]\u@\h:\w#\[\e[m\] ‘

To make the prompt green when running as a normal user add this to ~/.bashrc:

PS1=’\[\e[32m\]\u@\h:\w\$\[\e[m\] ‘

Update: If you want to add this to a kickstart script, do this:

# Help identify when logged in as root
echo “PS1=’\[\e[31m\]\u@\h:\w#\[\e[m\]‘” >> /root/.bashrc
echo “PS1=’\[\e[32m\]\u@\h:\w#\[\e[m\]‘” >> /etc/skel/.bashrc

Related posts:

  1. AD and sudo integratation in kickstart
  2. Permissions to cancel vCenter tasks
  3. Create local VMFS with 8MB block size during ESX4 kickstart install
Tags: , ,