Red Root Prompt

by Simfox

Many people would like a painless visual reminder that they are working as root when in the terminal. Here's a simple way to accomplish that.

Start your file manager as Superuser: "Start -> Applications -> File tools -> File Manager -> Super User Mode". Navigate to /etc. Add the following to the end of your /etc/bashrc file.

Now your root prompt will be red and your user prompt will be normal, according to your selected or default color scheme.

# Set Root Prompt to Red
function setprompt
{
local RED="\[$(tput setaf 1)\]"
local RESET="\[$(tput sgr0)\]"
if [ `id -u` = 0 ] # check if user is root
then
PS1="$RED[\u@\h:\W]$RESET "
else
PS1="[\u@\h:\W]$RESET"
fi
}
setprompt

Enjoy.

Top