Skip to content

Instantly share code, notes, and snippets.

@blahah
Created August 19, 2014 23:08
Show Gist options
  • Save blahah/49b1cd9d00b2e8a8dfa3 to your computer and use it in GitHub Desktop.
Save blahah/49b1cd9d00b2e8a8dfa3 to your computer and use it in GitHub Desktop.
bashrc pretty colours
set_prompt () {
Last_Command=$? # Must come first!
Blue='\[\e[01;34m\]'
White='\[\e[01;37m\]'
Red='\[\e[01;31m\]'
Green='\[\e[01;32m\]'
Reset='\[\e[00m\]'
FancyX='\342\234\227'
Checkmark='\342\234\223'
# Add a bright white exit status for the last command
PS1="$White\$? "
# If it was successful, print a green check mark. Otherwise, print
# a red X.
if [[ $Last_Command == 0 ]]; then
PS1+="$Green$Checkmark "
else
PS1+="$Red$FancyX "
fi
# If root, just print the host in red. Otherwise, print the current user
# and host in green.
if [[ $EUID == 0 ]]; then
PS1+="$Red\\h "
else
PS1+="$Green\\u@\\h "
fi
# Print the working directory and prompt marker in blue, and reset
# the text color to the default.
PS1+="$Blue\\w \\\$$Reset "
}
PROMPT_COMMAND='set_prompt'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment