Created
January 15, 2014 21:46
-
-
Save iamnewton/8445359 to your computer and use it in GitHub Desktop.
Changes the prompt (PS1) to green text for a normal user, red for root, and yellow for any other user attained via sudo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
color_root=$(tput setaf 1) | |
color_user=$(tput setaf 2) | |
color_sudo=$(tput setaf 3) | |
color_reset=$(tput sgr0) | |
// root user | |
if (( EUID == 0 )); then | |
PS1="\\[$color_root\\]$PS1\\[$color_reset\\]" | |
// sudo user | |
elif [[ $SUDO_USER ]]; then | |
PS1="\\[$color_sudo\\]$PS1\\[$color_reset\\]" | |
// all other users | |
else | |
PS1="\\[$color_user\\]$PS1\\[$color_reset\\]" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment