Command prompt with color exit smiley face
Here's a neat little trick that you can use to display a color exit code smiley face on your shell prompt.
When the previous code exits with a 0, a green smiley face is displayed; if it exits with anything other than 0, then a red sad face is displayed.
victor@Desktop:~ :) $ cd /tmp
victor@Desktop:/tmp :) $ ls 123
ls: cannot access 123: No such file or directory
victor@Desktop:~ :(
Simply change the PS1 variable in your profile (or you shell rc file) to the code below:
PS1='\u@\h:\w `if [ $? = 0 ]; then echo \[\e[32m\]:\)\[\e[37m\]; else echo \[\e[31m\]:\(\[\e[37m\]; fi` $ '
Written by Victor Mendonca
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Related Tags
#bash
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#