<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog.watashii &#187; colors</title>
	<atom:link href="http://blog.watashii.com/tag/colors/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.watashii.com</link>
	<description></description>
	<lastBuildDate>Wed, 02 Nov 2011 02:23:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Unix LS Command With Colors&#8230; Without the &#8212;color Option</title>
		<link>http://blog.watashii.com/2009/10/unix-ls-command-with-colors-without-the-color-option/</link>
		<comments>http://blog.watashii.com/2009/10/unix-ls-command-with-colors-without-the-color-option/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 15:43:08 +0000</pubDate>
		<dc:creator>watashii</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[colors]]></category>
		<category><![CDATA[ls]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.watashii.com/?p=262</guid>
		<description><![CDATA[Having command line text in colors makes things easier to read.  For example the ls command for listing directories and files.  In some Unix environments, the ls command may not support the &#8211;color option to let us do that (as it  requires GNU ls).  So how can we workaround this to add color to ls? [...]


Related Posts:<ol><li><a href='http://blog.watashii.com/2008/09/unix-ps-command-long-process-listing/' rel='bookmark' title='Permanent Link: Unix ps command &#8211; Long Process Listing'>Unix ps command &#8211; Long Process Listing</a></li>
<li><a href='http://blog.watashii.com/2008/08/unix-file-size-listing-du-command/' rel='bookmark' title='Permanent Link: UNIX file size listing &#8211; du command'>UNIX file size listing &#8211; du command</a></li>
<li><a href='http://blog.watashii.com/2008/07/unix-creating-chron-jobs-with-chrontab/' rel='bookmark' title='Permanent Link: Unix &#8211; Creating Cron Jobs with Crontab'>Unix &#8211; Creating Cron Jobs with Crontab</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-268" title="lscolor03" src="http://blog.watashii.com/wp-content/uploads/2009/10/lscolor03.png" alt="lscolor03" width="500" height="81" /></p>
<p>Having command line text in colors makes things easier to read.  For example the <em>ls </em>command for listing directories and files.  In some Unix environments, the  <a href="http://en.wikipedia.org/wiki/Ls" target="_blank"><em>ls</em></a> command may not support the <em>&#8211;color</em> option to let us do that (as it  requires GNU <em>ls</em>).  So how can we workaround this to add color to <em>ls</em>?</p>
<p>Here are my steps to make it happen. Note i&#8217;m no Unix guru, and I didn&#8217;t have time to perfect it.. but it gets the job done!</p>
<p><span id="more-262"></span></p>
<h3>1) Basic test. Echo some random color text.  I had to specify the full path of echo to make it work. The value <strong>01;34 </strong>is the color code for light blue.</h3>
<p><code>/bin/echo "\033[0m\033[<strong>01;34m</strong><em>this is blue text</em>\033[0m"</code></p>
<p><img class="alignnone size-full wp-image-270" title="lscolor01" src="http://blog.watashii.com/wp-content/uploads/2009/10/lscolor01.png" alt="lscolor01" width="575" height="53" /></p>
<h3>2) Here are some other color codes.</h3>
<pre><code>Black       0;30     Dark Gray     1;30
Blue        0;34     Light Blue    1;34
Green       0;32     Light Green   1;32
Cyan        0;36     Light Cyan    1;36
Red         0;31     Light Red     1;31
Purple      0;35     Light Purple  1;35
Brown       0;33     Yellow        1;33
Light Gray  0;37     White         1;37</code></pre>
<h3>3) Here are the ls commands I would like to color&#8230; with a bit of help from Google somewhere.</h3>
<p><code>ls -ld .*/             # List hidden directories<br />
ls -ld */              # List visible directories<br />
ls -lAd .* |grep '^-'  # List hidden files<br />
ls -l |grep '^-'       # List visible files</code></p>
<h3>4) Combining 1 and 3, gives me the following commands:</h3>
<p><code>/bin/echo "\033[0m\033[01;34m`ls -ld .*/`\033[0m"<br />
/bin/echo "\033[0m\033[01;32m`ls -ld */`\033[0m"<br />
/bin/echo "\033[0m\033[00;31m`ls -lAd .* |grep '^-'`\033[0m"<br />
/bin/echo "\033[0m\033[01;33m`ls -l |grep '^-'`\033[0m"</code></p>
<h3>5) Mash it together, assign it to an alias, and thats it! One single action does the job!</h3>
<p><code>alias ll='/bin/echo "\033[0m\033[01;34m`ls -ld .*/`\033[0m" ; /bin/echo "\033[0m\033[01;32m`ls -ld */`\033[0m" ; /bin/echo "\033[0m\033[00;31m`ls -lAd .* |grep '^-'`\033[0m" ; /bin/echo "\033[0m\033[01;33m`ls -l |grep '^-'`\033[0m"'</code></p>
<p><img title="lscolor02" src="http://blog.watashii.com/wp-content/uploads/2009/10/lscolor02.png" alt="lscolor02" width="550" height="502" /></p>


<p>Related Posts:<ol><li><a href='http://blog.watashii.com/2008/09/unix-ps-command-long-process-listing/' rel='bookmark' title='Permanent Link: Unix ps command &#8211; Long Process Listing'>Unix ps command &#8211; Long Process Listing</a></li>
<li><a href='http://blog.watashii.com/2008/08/unix-file-size-listing-du-command/' rel='bookmark' title='Permanent Link: UNIX file size listing &#8211; du command'>UNIX file size listing &#8211; du command</a></li>
<li><a href='http://blog.watashii.com/2008/07/unix-creating-chron-jobs-with-chrontab/' rel='bookmark' title='Permanent Link: Unix &#8211; Creating Cron Jobs with Crontab'>Unix &#8211; Creating Cron Jobs with Crontab</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.watashii.com/2009/10/unix-ls-command-with-colors-without-the-color-option/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

