Last active
March 1, 2024 05:28
-
-
Save textarcana/a76b86f6a0fce2340879 to your computer and use it in GitHub Desktop.
Show a green smiley or red frowny face to inidicate whether the last command exited with a good or bad exit status.
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
RESET="\[\017\]" | |
NORMAL="\[\033[0m\]" | |
RED="\[\033[31;1m\]" | |
GREEN="\[\033[32;1m\]" | |
SMILEY="${GREEN}:)${NORMAL}" | |
FROWNY="${RED}:(${NORMAL}" | |
EMOTE="if [ \$? = 0 ]; then echo \"${SMILEY}\"; else echo \"${FROWNY}\"; fi" | |
export PS1="${RESET}\n\`${EMOTE}\` \ | |
\u@\h \ | |
\n\$ " |
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
# Here is how I use the above code in my ~/.profile | |
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" | |
function parse_git_hash { | |
git log --format="%h" -n1 2> /dev/null | |
} | |
function parse_git_branch { | |
git branch 2> /dev/null | egrep '^\*\s+' | cut -c3- | |
} | |
export PS1="${RESET}\n\`${EMOTE}\` \ | |
\u@\h \ | |
\`${git_status_color}\`\$(parse_git_branch) \$(parse_git_hash)${NORMAL} \ | |
\w \ | |
\n\t \D{%b %d %Y %z %Z} \ | |
\n\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment