{"id":646,"date":"1997-09-09T01:36:29","date_gmt":"1997-09-09T09:36:29","guid":{"rendered":"http:\/\/www.birdhouse.org\/betips\/?p=646"},"modified":"1997-09-09T01:36:29","modified_gmt":"1997-09-09T09:36:29","slug":"colourful-file-listings-in-the-terminal","status":"publish","type":"post","link":"https:\/\/www.betips.net\/?p=646","title":{"rendered":"Colourful file listings in the terminal"},"content":{"rendered":"<p>If you are bored of the plain black and white colour file listings when you type &#8222;ls&#8220; in your Terminal, you can actually make the ls command colour the files based on their type (not mime type, but directory, symlink, etc) and extension.<br \/>\nIf you add the switch -C or &#8211;color to the ls command (i.e.)<\/p>\n<pre>ls -F -color<\/pre>\n<p>then you should get somewhat more interesting output!<br \/>\nIf you want to have some control over the colours that are displayed for each file type, create a file called <code>.dircolours<\/code> (or similar) in your home directory containing an entry for each terminal type (i.e. beterm or xterm) and the list of file extensions along with their colours. The example below demonstrates how this works.<br \/>\n<i=pre><br \/>\nCOLOR tty<br \/>\nTERM beterm<br \/>\nTERM xterm<br \/>\nEIGHTBIT 1<br \/>\nNORMAL 00       # global default, although everything should be something.<br \/>\nFILE 00         # normal file<br \/>\nDIR 00;32       # directory<br \/>\nLINK 01;36      # symbolic link<br \/>\nFIFO 40;33      # pipe<br \/>\nSOCK 01;35      # socket<br \/>\nBLK 40;33;01    # block device driver<br \/>\nCHR 40;33;01    # character device driver<br \/>\nEXEC 01;33<br \/>\n*~   05;31 # stuff we hate to find laying around (flashing red)<br \/>\n.c   00;35 # source code<br \/>\n.cpp 00;35<br \/>\n.h   00;36<br \/>\n.pl  00;35<br \/>\n.pm  00;35<br \/>\n.cgi 00;35<br \/>\n.html 04;35<br \/>\n.tar 00;31 # archives or compressed (bright red)<br \/>\n.tgz 00;31<br \/>\n.arj 00;31<\/p>\n<p>Once you have saved this file somewhere you need to add the following commands to your <code>.profile<\/code> (or <code>.bashrc<\/code> is probably better), replacing the <code>.dircolours<\/code> filename with whatever you used&#8230;<\/p>\n<pre>\neval `dircolors ~\/.dircolours`\nalias ls='ls --color=always'\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you are bored of the plain black and white colour file listings when you type &#8222;ls&#8220; in your Terminal, you can actually make the ls command colour the files based on their type (not mime type, but directory, symlink, etc) and extension. If you add the switch -C or &#8211;color to the ls command [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[11],"class_list":["post-646","post","type-post","status-publish","format-standard","hentry","tag-terminal"],"_links":{"self":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts\/646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=646"}],"version-history":[{"count":0,"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts\/646\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}