Skip to content

Instantly share code, notes, and snippets.

@jakebiesinger
Last active December 21, 2015 18:49
Show Gist options
  • Save jakebiesinger/6349778 to your computer and use it in GitHub Desktop.
Save jakebiesinger/6349778 to your computer and use it in GitHub Desktop.
Terminal prompt showing random, green happy unicode faces or angry red faces, depending on the exit code.
# emoticon version :) :(
export PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \`if [ \$? = 0 ]; then echo -e '\[\e[01;32m\]:)'; else echo -e '\[\e[01;31m\]:( ('$?')'; fi\` \[\033[00m\]\n\$ "
# simple unicode version ¬_¬ 😱
export PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \`if [ \$? = 0 ]; then echo -e '\[\e[01;32m\]¬_¬'; else echo -e '\[\e[01;31m\]😱 ('$?')'; fi\` \[\033[00m\]\n\$ "
# randomly selected smiles / frowns... see more at http://wrttn.me/30dbfd/
smiles="¬_¬
(^o^)
o_o
☆彡
(^0_0^)
:)"
smiles=($smiles)
num_smiles=${#smiles[*]}
frowns="●~*
(╯°□°)╯︵┻━┻
( ゚Д゚)
<コ:彡
</3
O.o
😱
๏_๏
☹ 🔫
﴾͡๏̯͡๏﴿ O'RLY?
(︺︹︺)
:("
frowns=($frowns)
num_frowns=${#frowns[*]}
face() {
code=$?
if [ $code = 0 ]
then printf "\e[01;32m${smiles[$((RANDOM%num_smiles))]}"
else printf "\e[01;31m${frowns[$((RANDOM%num_frowns))]} ($code)"
fi
}
export PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[00m\]$(__git_ps1) \$(face) \[\033[00m\]\n\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment