{"id":620,"date":"2012-01-29T20:38:34","date_gmt":"2012-01-29T20:38:34","guid":{"rendered":"http:\/\/cdblog.cdstealer.com\/?p=620"},"modified":"2012-07-18T06:21:30","modified_gmt":"2012-07-18T05:21:30","slug":"bash-colours","status":"publish","type":"post","link":"https:\/\/cdblog.cdstealer.com\/?p=620","title":{"rendered":"Bash Colours"},"content":{"rendered":"<p>Example:<br \/>\necho -e \"\\e[1;34mThis is a blue text.\\e[0m\"<\/p>\n<p>Explanation:<br \/>\nBash uses numeric codes to set attributes of the text to be displayed.<\/p>\n<p>Attribute codes:<br \/>\n00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed<\/p>\n<p>Text colour codes:<br \/>\n30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white<\/p>\n<p>Background colour codes:<br \/>\n40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white<\/p>\n<p>In the example above, I used the ANSI escape sequence \\e[attribute code;text colour codem to display a blue text. Therefore, we have to use -e option in calling echo to escape the input. Note that the colour effect had to be ended by \\e[0m to prevent the display of the prompt with different colours. However, the effects are sometimes interesting. I encourage you to play around with it.<\/p>\n<p>To have a background, we must use the background colour codes. The sequence then becomes \\e[attribute code;text colour code;background colour codem. As you can guess, any missing code is simply taken as zero value by bash. Provided you shell supports 8-bit colours (the new Cygwin version 1.43 and a00.seng.engr do), you can display a coloured welcome message when you log into bash should you wish to.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Example: echo -e \"\\e[1;34mThis is a blue text.\\e[0m\" Explanation: Bash uses numeric codes to set attributes of the text to be displayed. Attribute codes: 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed Text colour codes: 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white Background colour codes: 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white In the example &hellip; <a href=\"https:\/\/cdblog.cdstealer.com\/?p=620\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Bash Colours<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[86,113,18],"class_list":["post-620","post","type-post","status-publish","format-standard","hentry","category-gentoo","tag-bash","tag-colour","tag-linux"],"_links":{"self":[{"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/posts\/620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=620"}],"version-history":[{"count":4,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/posts\/620\/revisions"}],"predecessor-version":[{"id":647,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/posts\/620\/revisions\/647"}],"wp:attachment":[{"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}