Skip to content

Instantly share code, notes, and snippets.

@presheaf
Created February 22, 2017 15:48
Show Gist options
  • Save presheaf/9a4343974d02eb7ed650bdd3f249bd8c to your computer and use it in GitHub Desktop.
Save presheaf/9a4343974d02eb7ed650bdd3f249bd8c to your computer and use it in GitHub Desktop.
### source this to make your prompt very aesthetically pleasing. Probably change bayaz to your computer's name.
RED='\033[0;31m'
GREEN='\033[0;32m'
INVERTED='\e[7m'
NC='\033[0m' # No Color
if [ $HOSTNAME = 'bayaz' ]
then
export HOST_COLOR='\e[32m' #green
else
export HOST_COLOR='\e[35m' #magenta
fi
prompt () {
last_code="$?"
# glyph indicating rootness/previous command exit code
if [ ${EUID} == "0" ]
then
# root
echo -e "$RED$INVERTED:S$NC"
else
if [ "$last_code" == "0" ]
then
# last command succeeded
echo -e "$GREEN:)$NC"
else
# last command failed
echo -e "$RED>:($NC"
fi
fi
}
export PS1="\$(prompt) $HOST_COLOR\h$NC:\w \n "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment