{"id":118,"date":"2010-05-24T10:55:40","date_gmt":"2010-05-24T10:55:40","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=118"},"modified":"2012-08-23T15:06:11","modified_gmt":"2012-08-23T15:06:11","slug":"118","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=118","title":{"rendered":"Enabling Terminal\u2019s directory and file colour highlighting in Mac OS X"},"content":{"rendered":"<p>By default\u00a0<a title=\"Apple - Mac OS X\" href=\"http:\/\/www.apple.com\/macosx\/\" rel=\"nofollow\" target=\"_blank\">Mac OS X<\/a>\u2019s\u00a0<strong>Terminal<\/strong> application uses the\u00a0<a title=\"Wikipedia - Bash\" href=\"http:\/\/en.wikipedia.org\/wiki\/Bash\" rel=\"nofollow\" target=\"_blank\">Bash<\/a> shell (<em>Bourne Again SHell<\/em>) but doesn\u2019t have\u00a0<strong>directory and file colour highlighting<\/strong> enabled to indicate<strong>resource types<\/strong> and\u00a0<strong>permissions settings<\/strong>.<\/p>\n<p><a href=\"https:\/\/blog.designed79.co.uk\/wp-content\/uploads\/2010\/05\/mac-terminal-directory-file-highlighting.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-1236\" title=\"mac-terminal-directory-file-highlighting\" src=\"https:\/\/blog.designed79.co.uk\/wp-content\/uploads\/2010\/05\/mac-terminal-directory-file-highlighting.png\" alt=\"\" width=\"480\" height=\"651\" srcset=\"https:\/\/blog.designed79.co.uk\/wp-content\/uploads\/2010\/05\/mac-terminal-directory-file-highlighting.png 480w, https:\/\/blog.designed79.co.uk\/wp-content\/uploads\/2010\/05\/mac-terminal-directory-file-highlighting-221x300.png 221w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><\/p>\n<p>Enabling\u00a0<strong>directory and file colour highlighting<\/strong> requires that you open (<em>or create<\/em>)<strong>~\/.bash_profile<\/strong> in your favourite text editor, add these contents:<\/p>\n<pre>export CLICOLOR=1\r\nexport LSCOLORS=ExFxCxDxBxegedabagacad<\/pre>\n<p>\u2026 save the file and open a new\u00a0<strong>Terminal<\/strong> window (<em>shell session<\/em>). Any variant of the \u201c<strong>ls<\/strong>\u201d command:<\/p>\n<pre>ls\r\nls -l\r\nls -la\r\nls -lah<\/pre>\n<p>\u2026 will then display its output in color.<\/p>\n<p>More details on the\u00a0<strong>LSCOLORS<\/strong> variable can be found by looking at the\u00a0<strong>man<\/strong> page for \u201c<strong>ls<\/strong>\u201c:<\/p>\n<pre>man ls<\/pre>\n<p><strong>LSCOLORS needs 11 sets of letters indicating foreground and background colors:<\/strong><\/p>\n<ol>\n<li>directory<\/li>\n<li>symbolic link<\/li>\n<li>socket<\/li>\n<li>pipe<\/li>\n<li>executable<\/li>\n<li>block special<\/li>\n<li>character special<\/li>\n<li>executable with setuid bit set<\/li>\n<li>executable with setgid bit set<\/li>\n<li>directory writable to others, with sticky bit<\/li>\n<li>directory writable to others, without sticky bit<\/li>\n<\/ol>\n<p>The possible letters to use are:<\/p>\n<pre>a  black\r\nb  red\r\nc  green\r\nd  brown\r\ne  blue\r\nf  magenta\r\nc  cyan\r\nh  light grey\r\nA  block black, usually shows up as dark grey\r\nB  bold red\r\nC  bold green\r\nD  bold brown, usually shows up as yellow\r\nE  bold blue\r\nF  bold magenta\r\nG  bold cyan\r\nH  bold light grey; looks like bright white\r\nx  default foreground or background<\/pre>\n<p>By referencing these values, the\u00a0<strong>LSCOLORS<\/strong> variable setting mentioned above translates to:<\/p>\n<p><em>Bold blue with default background for\u00a0<strong>directories<\/strong>, bold magenta with default background for\u00a0<strong>symbolic links<\/strong>, bold green with default background for\u00a0<strong>sockets<\/strong>, etc.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default\u00a0Mac OS X\u2019s\u00a0Terminal application uses the\u00a0Bash shell (Bourne Again SHell) but doesn\u2019t have\u00a0directory and file colour highlighting enabled to indicateresource types [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=118"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}