{"id":82,"date":"2020-12-08T22:10:47","date_gmt":"2020-12-08T22:10:47","guid":{"rendered":"https:\/\/www.codefraction.com\/?p=82"},"modified":"2021-01-17T18:02:06","modified_gmt":"2021-01-17T16:02:06","slug":"customizing-your-bash-shell-for-better-reading-experience","status":"publish","type":"post","link":"https:\/\/www.codefraction.com\/index.php\/2020\/12\/08\/customizing-your-bash-shell-for-better-reading-experience\/","title":{"rendered":"Customizing your bash shell for better reading experience in terminal"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"82\" class=\"elementor elementor-82\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-22b84131 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"22b84131\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-narrow\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4478757\" data-id=\"4478757\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0421967 elementor-widget elementor-widget-theme-post-title elementor-page-title elementor-widget-heading\" data-id=\"0421967\" data-element_type=\"widget\" data-widget_type=\"theme-post-title.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h1 class=\"elementor-heading-title elementor-size-default\">Customizing your bash shell for better reading experience in terminal<\/h1>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3200c4c elementor-align-left elementor-widget elementor-widget-global elementor-global-471 elementor-widget-post-info\" data-id=\"3200c4c\" data-element_type=\"widget\" data-widget_type=\"post-info.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<ul class=\"elementor-inline-items elementor-icon-list-items elementor-post-info\">\n\t\t\t\t\t\t\t\t<li class=\"elementor-icon-list-item elementor-repeater-item-a9d1b46 elementor-inline-item\" itemprop=\"datePublished\">\n\t\t\t\t\t\t<a href=\"https:\/\/www.codefraction.com\/index.php\/2020\/12\/08\/\">\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-icon\">\n\t\t\t\t\t\t\t\t<i aria-hidden=\"true\" class=\"fas fa-calendar\"><\/i>\t\t\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-date\">\n\t\t\t\t\t\t\t\t\t\t<time>December 8, 2020<\/time>\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t<li class=\"elementor-icon-list-item elementor-repeater-item-8fee4f0 elementor-inline-item\" itemprop=\"about\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-icon\">\n\t\t\t\t\t\t\t\t<i aria-hidden=\"true\" class=\"fas fa-tags\"><\/i>\t\t\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-terms\">\n\t\t\t\t\t\t\t<span class=\"elementor-post-info__item-prefix\">Tags: <\/span>\n\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-post-info__terms-list\">\n\t\t\t\t<a href=\"https:\/\/www.codefraction.com\/index.php\/tag\/bash\/\" class=\"elementor-post-info__terms-list-item\">Bash<\/a>, <a href=\"https:\/\/www.codefraction.com\/index.php\/tag\/command-line\/\" class=\"elementor-post-info__terms-list-item\">Command Line<\/a>, <a href=\"https:\/\/www.codefraction.com\/index.php\/tag\/shell\/\" class=\"elementor-post-info__terms-list-item\">Shell<\/a>, <a href=\"https:\/\/www.codefraction.com\/index.php\/tag\/terminal\/\" class=\"elementor-post-info__terms-list-item\">Terminal<\/a>\t\t\t\t<\/span>\n\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t<\/li>\n\t\t\t\t<\/ul>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-675d34b elementor-widget elementor-widget-heading\" data-id=\"675d34b\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Customizing:<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-88dbd73 elementor-widget elementor-widget-text-editor\" data-id=\"88dbd73\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>If you are using a lot of\u00a0 terminal \/ command line and bash shell, you might have experiences that some times it is bit difficult to read the terminal. For example in cases that you have long lists of texts and you print those lists several times, you might lose track, when one list ends and when another list starts as the text is all the same color.\u00a0 As a solution we will add some color coding to the bash shell \/ terminal. Some bash shells \/ terminals will have this color coding enabled by default for example in some Linux distros. But for example in my bash shell under Mac OS we don&#8217;t have any color coding:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9d77c76 elementor-widget elementor-widget-image\" data-id=\"9d77c76\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/www.codefraction.com\/wp-content\/uploads\/2020\/12\/Before.png\" title=\"Before color coding\" alt=\"Before color coding\" loading=\"lazy\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1a18d0a elementor-widget elementor-widget-text-editor\" data-id=\"1a18d0a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>So let&#8217;s change that boring look to this one:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9c3a623 elementor-widget elementor-widget-image\" data-id=\"9c3a623\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"580\" height=\"363\" src=\"https:\/\/www.codefraction.com\/wp-content\/uploads\/2020\/12\/AfterCustomizing.png\" class=\"attachment-large size-large wp-image-205\" alt=\"After color coding\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c6856b7 elementor-widget elementor-widget-text-editor\" data-id=\"c6856b7\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>To get this style of color coding, we create a .bash_profile file in our home directory for example with Emacs text editor. In the file we will add the following lines:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9ff3084 elementor-widget elementor-widget-text-editor\" data-id=\"9ff3084\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><em># You can comment in the file after hashtag and one empty space<br \/><\/em><\/p>\n<p>\u00a0<\/p>\n<p><em># Enable color coding<\/em><\/p>\n<p><em>export CLICOLOR=1<\/em><\/p>\n<p>\u00a0<\/p>\n<p><em># With the next line we can customize which colors to use and how to for example show <\/em><em>username, computer\/host name <br \/># and current folder. You can reorder the username, host name and current folder in any order you want. Or you can even<br \/># leave some out, if you don&#8217;t need. But in my example I will order them as follow: <\/em><em>username @ host name : folder$<\/em><\/p>\n<p>\u00a0<\/p>\n<p><em># \\[\\e[32m\\] = Use green color<\/em><\/p>\n<p><em># \\u = Username<\/em><\/p>\n<p><em># \\h = Host name<br \/><\/em><\/p>\n<p><em># \\W = Current folder<br \/><\/em><\/p>\n<p><em># \\[\\e[0m\\] = Reset text color (so go back to using white color)<br \/><\/em><\/p>\n<p><em>export PS1=&#8221;\\[\\e[32m\\]\\u@\\h:\\W$ \\[\\e[0m\\]&#8221;<\/em><\/p>\n<p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-66e1a61 elementor-widget elementor-widget-text-editor\" data-id=\"66e1a61\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>And if you aren&#8217;t happy with the green color, you can replace it with some other color:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9f52e2f elementor-widget elementor-widget-text-editor\" data-id=\"9f52e2f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><em>\\[\\e[30m\\]\u00a0 = Black<br \/><\/em><em>\\[\\e[31m\\]\u00a0 = Red<br \/>\\[\\e[32m\\]\u00a0 = Green<br \/><\/em><em>\\[\\e[33m\\]\u00a0 = Yellow<br \/><\/em><em>\\[\\e[34m\\]\u00a0 = Blue<br \/>\\[\\e[35m\\]\u00a0 = Purple<br \/>\\[\\e[36m\\]\u00a0 = Cyan<br \/>\\[\\e[37m\\]\u00a0 = White<\/em><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-678f5b9 elementor-widget elementor-widget-spacer\" data-id=\"678f5b9\" data-element_type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-96a44cb elementor-widget elementor-widget-heading\" data-id=\"96a44cb\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">More Customizing:<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b82449d elementor-widget elementor-widget-text-editor\" data-id=\"b82449d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>If you want to customize even more, you can change the color of the folder, symbolic link, etc. So for example when you run the ls command to list what&#8217;s under the current directory, for example the folders would be in red colored text. If you want to do that you can add this following in the .bash_profile after the &#8220;export CLICOLOR=1&#8221;:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7d2253e elementor-widget elementor-widget-text-editor\" data-id=\"7d2253e\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><em>export LSCOLORS=ExFxBxDxCxegedabagacad<br \/><\/em><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4a10c89 elementor-widget elementor-widget-text-editor\" data-id=\"4a10c89\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>These values are read as a pair (for example &#8220;Ex&#8221;, &#8220;Fx&#8221;, &#8220;Bx&#8221;, etc). For example the first value in &#8220;Ex&#8221; (the value &#8220;E&#8221;) means that item&#8217;s text color should be bold blue. The second value &#8220;x&#8221; means default background color (so don&#8217;t change the background color). Here&#8217;s the order what each pair means, first will be the color of folder, second pair will be the color of symbolic link etc:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-486cd78 elementor-widget elementor-widget-text-editor\" data-id=\"486cd78\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><em>1 = folder<br \/>2 = symbolic link<br \/>3 = socket<br \/>4 = pipe<br \/>5 = executable<br \/>6 = block special<br \/>7 = character special<br \/>8 = executable with setuid bit set<br \/>9 = executable with setgid bit set<br \/>10 = directory writable to others, with sticky bit<br \/>11 = directory writable to others, without sticky bit<br \/><\/em><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f5b3de0 elementor-widget elementor-widget-text-editor\" data-id=\"f5b3de0\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>And here&#8217;s the color values:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-42972a8 elementor-widget elementor-widget-text-editor\" data-id=\"42972a8\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><em>a = black<br \/>b = red<br \/>c = green<br \/>d = brown<br \/>e = blue<br \/>f = magenta<br \/>g = cyan<br \/>h = light grey<br \/>A = bold black (might show as dark grey also)<br \/>B = bold red<br \/>C = bold green<br \/>D = bold brown (might show as yellow also)<br \/>E = bold blue<br \/>F = bold magenta<br \/>G = bold cyan<br \/>H = bold light grey<br \/>x = default text color \/ background<br \/><\/em><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-98c0ff6 elementor-widget elementor-widget-spacer\" data-id=\"98c0ff6\" data-element_type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-760913c elementor-widget elementor-widget-heading\" data-id=\"760913c\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Sources:<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bef651b elementor-widget elementor-widget-text-editor\" data-id=\"bef651b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Articles that I have found useful myself when I was searching information how to customize bash shell. Thanks for these authors for writing these articles. I have quoted the color value and pair value lists from them.<br><br><\/p>\n<p><a href=\"https:\/\/osxdaily.com\/2012\/02\/21\/add-color-to-the-terminal-in-mac-os-x\/\" target=\"_blank\">https:\/\/osxdaily.com\/2012\/02\/21\/add-color-to-the-terminal-in-mac-os-x\/<\/a><br><a href=\"https:\/\/www.maketecheasier.com\/customize-mac-terminal\/\" target=\"_blank\">https:\/\/www.maketecheasier.com\/customize-mac-terminal\/<\/a><\/p>\n<p><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1c24402 elementor-widget elementor-widget-spacer\" data-id=\"1c24402\" data-element_type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Customizing: If you are using a lot of\u00a0 terminal \/ command line and bash shell, you might have experiences that some times it is bit difficult to read the terminal. For example in cases that you have long lists of texts and you print those lists several times, you might lose track, when one list [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"elementor_header_footer","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[8,12,9,11],"class_list":["post-82","post","type-post","status-publish","format-standard","hentry","category-linux","tag-bash","tag-command-line","tag-shell","tag-terminal"],"_links":{"self":[{"href":"https:\/\/www.codefraction.com\/index.php\/wp-json\/wp\/v2\/posts\/82","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codefraction.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codefraction.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codefraction.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codefraction.com\/index.php\/wp-json\/wp\/v2\/comments?post=82"}],"version-history":[{"count":223,"href":"https:\/\/www.codefraction.com\/index.php\/wp-json\/wp\/v2\/posts\/82\/revisions"}],"predecessor-version":[{"id":518,"href":"https:\/\/www.codefraction.com\/index.php\/wp-json\/wp\/v2\/posts\/82\/revisions\/518"}],"wp:attachment":[{"href":"https:\/\/www.codefraction.com\/index.php\/wp-json\/wp\/v2\/media?parent=82"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codefraction.com\/index.php\/wp-json\/wp\/v2\/categories?post=82"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codefraction.com\/index.php\/wp-json\/wp\/v2\/tags?post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}