0

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
1
Contributor
0
Replies
2
Views
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.