Smiley Face Bash Prompt

PS1="\`if [ \$? = 0 ]; then echo \e[33\;40m\\\^\\\_\\\^\e[0m; else echo \e[36\;40m\\\-\e[0m\\\_\e[36\;40m\\\-\e[0m; fi\` \u \w:\h)"
If your last command was a dud, your bash prompt will be angry at you. Otherwise it's happy. Soon you will crave its constant approval and your linux skills will improve simply to avoid low self-esteem.
Sample Output
^_^ # true
^_^ # false
-_- #

2009-06-30 14:29:55

What Others Think

haha! love it!
nottings · 591 weeks ago
Very good. Is not for men?
point_to_null · 591 weeks ago
a bit emo, but very amusing!
irae · 591 weeks ago
it is a very fun command. However, the open colors screw with the ability of (at least gnome-terminal) wrapping text to the next line. Be sure to open and close around each color set to fix this. example: \[\e[36\;40m\]. and when setting back to defaults, leave the semicolon outside. example: \[\e[0m\];
random_bob · 590 weeks and 5 days ago
Thanks. Now, my prompt has officially been rendered unreadable ;-) PS1="\[\033[0;33m\]\[email protected]\h\[\033[0m\]:\[\033[0;36m\]\A\[\033[0m\]:\`if [ \$? = 0 ]; then echo \e[33\;40m\\\^\\\_\\\^\e[0m; else echo \e[36\;40m\\\-\e[0m\\\_\e[36\;40m\\\-\e[0m; fi\`:\[\033[1;34m\]\w\[\033[0m\]>\[\033[0m\] "
Alanceil · 590 weeks and 5 days ago
"Edit": Cleaned up edition with less escapes and a transparent background for the smiley (instead of black): PS1="\033[0;32m\[email protected]\h\033[0m:\033[0;36m\A\033[0m:\`if [ \$? = 0 ]; then echo '\033[1;30m^_^\033[0m'; else echo '\033[0;33m>_>\033[0m' ; fi\`:\033[1;34m\w\033[0m>\033[0m "
Alanceil · 590 weeks and 5 days ago
I went along the same lines, but closed the color codes; PS1="\`if [ \$? = 0 ]; then echo \[\e[34m\]^_^\[\e[0m\]; else echo \[\e[31m\]O_O\[\e[0m\]; fi\`[\[email protected]\h:\w]\\$ " this way it handles text wrap for long commands (like this one)
random_bob · 590 weeks and 1 day ago
Here are some more advanced prompts:
AskApache · 213 weeks and 2 days ago
Can't get it. Just want to know the Best NFL players to pick for fantasy football
paultribbiani · 9 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: