Skip to content

Instantly share code, notes, and snippets.

@textarcana
Last active November 14, 2024 17:48
Show Gist options
  • Save textarcana/0314d666195a6356f6396116cd56007a to your computer and use it in GitHub Desktop.
Save textarcana/0314d666195a6356f6396116cd56007a to your computer and use it in GitHub Desktop.
bash smiley face that changes based on exit status. Based on some stack exchange posts I read a long time ago.
# Smiley face prompt if the last command would have been a
# passing Jenkins build step.
#
# Add this to your shell config file.
#
# A smiley face if the exit status of the last command was 0.
#
# Otherwise a frowny face.
RESET="\[\017\]"
NORMAL="\[\033[0m\]"
RED="\[\033[31;1m\]"
YELLOW="\[\033[33;1m\]"
GREEN="\[\033[32;1m\]"
WHITE="\[\033[37;1m\]"
SMILEY="${GREEN}:)${NORMAL}"
FROWNY="${RED}:(${NORMAL}"
EMOTE="if [ \$? = 0 ]; then echo \"${SMILEY}\"; else echo \"${FROWNY}\"; fi"
git_status_color="if [[ \$(git status -s 2> /dev/null) == '' ]]; then echo \"${GREEN}\"; else echo \"${YELLOW}\"; fi"
export PS1="${RESET}\n\`${EMOTE}\` \
\u@\h \
\w \
\n\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment