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
-_- #

18
2009-06-30 14:29:55

What Others Think

haha! love it!
nottings · 476 weeks and 2 days ago
Very good. Is not for men?
point_to_null · 476 weeks and 2 days ago
a bit emo, but very amusing!
irae · 476 weeks and 1 day 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 · 476 weeks ago
Thanks. Now, my prompt has officially been rendered unreadable ;-) PS1="\[\033[0;33m\]\u@\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 · 476 weeks ago
"Edit": Cleaned up edition with less escapes and a transparent background for the smiley (instead of black): PS1="\033[0;32m\u@\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 · 476 weeks 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\`[\u@\h:\w]\\$ " this way it handles text wrap for long commands (like this one)
random_bob · 475 weeks and 3 days ago
Here are some more advanced prompts: http://www.askapache.com/linux/bash-power-prompt.html
AskApache · 98 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?

commandlinefu.com 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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: