954,546 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Change color according to user

0
By ankur.dhoot on Oct 25th, 2007 7:30 pm

This code changes color of prompt according to user, suppose if user is root then color would be red and normal user would have color black. This'll diffrentiate in users.

if [ $(id -u) -eq 0 ];
then # you are root, set red colour prompt
  PS1="\[$(tput setaf 1)\]\u@\h:\w #\[$(tput sgr0)\]"
else # normal
  PS1="\u@\h:\w $"
fi

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You