{"id":136,"date":"2009-01-06T17:22:37","date_gmt":"2009-01-07T00:22:37","guid":{"rendered":"http:\/\/thesmithfam.org\/blog\/?p=136"},"modified":"2019-08-12T07:15:58","modified_gmt":"2019-08-12T13:15:58","slug":"best-bash-prompt-ever","status":"publish","type":"post","link":"https:\/\/thesmithfam.org\/blog\/2009\/01\/06\/best-bash-prompt-ever\/","title":{"rendered":"Best bash prompt. Ever."},"content":{"rendered":"<p>I have the best bash prompt ever. It took a lot of hacking and googling, but here she is:<\/p>\n<p><img decoding=\"async\" src=\"\/images\/bash-prompt.png\" \/><\/p>\n<p>Notice that the smiley face and text colors change depending on the exit code of the last run command (red = failed, green = happy). This is handy, for example, after a big long build that has error messages buried in it, and the last line of output just isn&#8217;t that useful.<\/p>\n<p>To make your prompt awesome, put this in your .bashrc and enjoy:<\/p>\n<pre><textarea wrap=\"off\" rows=\"25\" cols=\"50\">\r\nBLACK=\"\\[\\033[0;30m\\]\"\r\nDARK_GRAY=\"\\[\\033[1;30m\\]\"\r\nLIGHT_GRAY=\"\\[\\033[0;37m\\]\"\r\nBLUE=\"\\[\\033[0;34m\\]\"\r\nLIGHT_BLUE=\"\\[\\033[1;34m\\]\"\r\nGREEN=\"\\[\\033[0;32m\\]\"\r\nLIGHT_GREEN=\"\\[\\033[1;32m\\]\"\r\nCYAN=\"\\[\\033[0;36m\\]\"\r\nLIGHT_CYAN=\"\\[\\033[1;36m\\]\"\r\nRED=\"\\[\\033[0;31m\\]\"\r\nLIGHT_RED=\"\\[\\033[1;31m\\]\"\r\nPURPLE=\"\\[\\033[0;35m\\]\"\r\nLIGHT_PURPLE=\"\\[\\033[1;35m\\]\"\r\nBROWN=\"\\[\\033[0;33m\\]\"\r\nYELLOW=\"\\[\\033[1;33m\\]\"\r\nWHITE=\"\\[\\033[1;37m\\]\"\r\nDEFAULT_COLOR=\"\\[\\033[00m\\]\"\r\n\r\nexport PS1=\"\\`if [ \\$? = 0 ];\r\n    then\r\n        echo -e '$GREEN--( $LIGHT_CYAN\\u$YELLOW@$LIGHT_CYAN\\h$GREEN )--( $YELLOW\\w$GREEN )-- :)\\n--\\$$DEFAULT_COLOR ';\r\n    else\r\n        echo -e '$LIGHT_RED--( $LIGHT_CYAN\\u$YELLOW@$LIGHT_CYAN\\h$LIGHT_RED )--( $YELLOW\\w$LIGHT_RED )-- :(\\n--\\$$DEFAULT_COLOR ';\r\n    fi; \\`\"\r\n<\/textarea><\/pre>\n<p>Happy bashing!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have the best bash prompt ever. It took a lot of hacking and googling, but here she is: Notice that the smiley face and text colors change depending on the exit code of the last run command (red = failed, green = happy). This is handy, for example, after a big long build that [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-136","post","type-post","status-publish","format-standard","hentry","category-code-and-cruft"],"_links":{"self":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/comments?post=136"}],"version-history":[{"count":18,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/136\/revisions"}],"predecessor-version":[{"id":1549,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/136\/revisions\/1549"}],"wp:attachment":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/media?parent=136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/categories?post=136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/tags?post=136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}