{"id":8,"date":"2007-09-23T11:22:48","date_gmt":"2007-09-23T10:22:48","guid":{"rendered":"http:\/\/blog.nooblet.org\/?p=8"},"modified":"2013-01-10T04:41:56","modified_gmt":"2013-01-10T04:41:56","slug":"changing-colour-of-filesdirectories-in-linux-ls","status":"publish","type":"post","link":"https:\/\/www.nooblet.org\/blog\/2007\/changing-colour-of-filesdirectories-in-linux-ls\/","title":{"rendered":"Changing Colour of Files\/Directories in Linux &#8216;ls&#8217;"},"content":{"rendered":"<p>A default colour set is available in Debian for many file types. A quick look at ~\/.bashrc shows that we can uncomment a few lines to enable the colouring of directories and files by extension.<\/p>\n<p>The relevant lines in my ~\/.bashrc are,<\/p>\n<blockquote><p><code>export LS_OPTIONS='--color=auto'<br \/>\neval \"`dircolors`\"<br \/>\nalias ls='ls $LS_OPTIONS'<br \/>\nalias ll='ls $LS_OPTIONS -l'<br \/>\nalias l='ls $LS_OPTIONS -lA'<\/code><\/p><\/blockquote>\n<p>The command <code>dircolors<\/code> outputs the line needed to put the colour information into your environment space. A <code>man dircolor<\/code> revealed the ability to edit its output.<\/p>\n<p>Using <code>dircolors --print-database<\/code> you can get the list of colours in an editable form, so if we pipe that to a file,<\/p>\n<blockquote><p><code>dircolors --print-database > \/etc\/dircolors<\/code><\/p><\/blockquote>\n<p>We can edit this file name and add the colors we want. The file has some explanations as to what the numbers represent.<\/p>\n<p>I added a couple of lines so that .7z and .rar files appear the same as the other compressed archives did.<\/p>\n<blockquote><p><code>.tar 01;31 # archives or compressed (bright red)<br \/>\n.gz 01;31<br \/>\n.bz2 01;31<br \/>\n.deb 01;31<br \/>\n.rpm 01;31<br \/>\n.rar 01;31 # added<br \/>\n.7z 01;31 # added<\/code><\/p><\/blockquote>\n<p>Following this change we need to edit the ~\/.bashrc file again to use this new configuration file rather than the default in-built database. Just edit the line beginning with &#8220;eval&#8221; so it reads,<\/p>\n<blockquote><p><code>eval \"`dircolors \/etc\/dircolors`\"<\/code><\/p><\/blockquote>\n<p>Now you&#8217;ll find the new file extensions coloured how you want them. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A default colour set is available in Debian for many file types. A quick look at ~\/.bashrc shows that we can uncomment a few lines to enable the colouring of directories and files by extension. The relevant lines in my ~\/.bashrc are, export LS_OPTIONS=&#8217;&#8211;color=auto&#8217; eval &#8220;`dircolors`&#8221; alias ls=&#8217;ls $LS_OPTIONS&#8217; alias ll=&#8217;ls $LS_OPTIONS -l&#8217; alias l=&#8217;ls [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":648,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-8","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/8","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":3,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/8\/revisions"}],"predecessor-version":[{"id":775,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/8\/revisions\/775"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/media\/648"}],"wp:attachment":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/media?parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/categories?post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/tags?post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}