<?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>JDHarper.com &#187; cygwin</title>
	<atom:link href="http://jdharper.com/blog/tag/cygwin/feed/" rel="self" type="application/rss+xml" />
	<link>http://jdharper.com/blog</link>
	<description>Stuff Worth Writing About</description>
	<lastBuildDate>Thu, 15 Jul 2010 16:20:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Command Line Tools: weather, todo, wget, tweet, and solve</title>
		<link>http://jdharper.com/blog/command-line-tools-weather-todo-wget-tweet-and-solve/</link>
		<comments>http://jdharper.com/blog/command-line-tools-weather-todo-wget-tweet-and-solve/#comments</comments>
		<pubDate>Fri, 08 May 2009 22:58:43 +0000</pubDate>
		<dc:creator>J. D. Harper</dc:creator>
				<category><![CDATA[command line]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Now that Cygwin is just a keyboard shortcut away, it&#8217;s time to explore a little of what it can do. Download files: wget This is a tool built into Cygwin that makes it easy to download files without needing a web browser. Simply type wget [a url] to download a single file. But wget has [...]]]></description>
			<content:encoded><![CDATA[<p>Now that <a href="http://www.jdharper.com/blog/command-line-tools-post-0-the-quake-style-command-line">Cygwin is just a keyboard shortcut away</a>, it&#8217;s time to explore a little of what it can do.</p>
<h4 id="download_files_wget">Download files: wget</h4>
<p>This is a tool built into Cygwin that makes it easy to download files without needing a web browser. Simply type <code>wget [a url]</code> to download a single file. </p>
<p>But wget has a lot more features than that. For example, if you want to download a lot of files, you can save a list of URLs to a text file, putting each URL on its own line. Then, open cygwin and type <code>wget -i listoffiles.txt</code> and wget will download each file, one after another. </p>
<p>If you&#8217;re looking for more interesting ways to use wget, you&#8217;ll probably find this <a href="http://lifehacker.com/161202/geek-to-live--mastering-wget">Lifehacker post</a> relevant.</p>
<h4 id="get_weather_forecasts_weather">Get weather forecasts: weather</h4>
<p>When we&#8217;re finished, you will be able to type the word weather into the console and get back a list of current local weather conditions and a local weather forecast (<a href="http://www.jdharper.com/images/FULL-S_20090502_102849_1_1024x768.png">example</a>). We&#8217;ll be using <a href="http://fungi.yuggoth.org/weather/">a shell script written by Jeremy Stanley</a> to make this happen. </p>
<p><small>NOTE: Since this script pulls its forecast information from the U.S. National Weather Service, forecasts are only available for US territories. However, international readers can still get their current weather conditions since that data is provided by local airports.</small></p>
<ol>
<li>Download <a href="http://fungi.yuggoth.org/weather/src/">the latest version of the script</a>.</li>
<li>Open it by typing <code>tar -xvf [filename]</code> and change to the new folder by typing <code>cd [new folder name]</code>.</li>
<li><small><em>optional</em></small> If you want to try the script out, typing in <code>./weather ATL</code> will return the current conditions at the Atlanta airport.</li>
<li>Now, to get your local conditions/forecast, you&#8217;ll need to edit the <code>weatherrc</code> file in your favorite text editor. Add the following lines to the top of the file (after the copyright notice).<br />
<blockquote>
<p>[default]<br />
Forecast = True<br />
City = Greenville Spartanburg<br />
St = SC<br />
ID = KGSP</p>
</blockquote>
<p>That&#8217;s the configuration to get my local forecast. To get yours, we&#8217;ll need to change the city, st, and ID variables to your location.</p>
<p>To get a forecast, you&#8217;ll need to put in a city that the National Weather Service provides information for. <a href="http://weather.noaa.gov/pub/data/forecasts/city/">Go here</a> and select your state to find what cities are available. If you don&#8217;t want a forecast, just delete the <code>Forecast = True</code> line.</p>
<p>To get current conditions, you&#8217;ll need to provide the METAR id for your nearest airport. Go to <a href="http://en.allmetsat.com/metar-taf/index.html">this map</a> and click on the city closest to you. Under the map will be the METAR id for that airport.</p>
<p>Save the weatherrc file and type <code>./weather</code> into cygwin. It should give you a local forecast with current weather conditions.</p>
</li>
<li><small><em>optional</em></small> Let&#8217;s make it so that you can get your weather from anywhere in the file system and so that you don&#8217;t have to type that annoying <code>./</code> beforehand. We&#8217;re gonna have to move some files around.
<p>If it doesn&#8217;t already exist in your home folder, make a folder called bin (<code>mkdir bin</code>). Move just the <code>weather</code> file to that folder. Make sure it&#8217;s executable by typing <code>chmod +x weather</code>.</p>
<p>Next, type <code>python -c "import sys ; print sys.path"</code> to find out where to put <code>weather.py</code> and <code>weather.pyc</code>. I put mine in <code>/usr/lib/python2.5</code></p>
<p>Then, move <code>weather.1</code> and <code>weatherrc.5</code> to <code>/usr/share/local/man/man1</code>, which is where cygwin stores manual files. (Once you do this, you can type <code>man weather</code> or <code>man weatherrc</code> to find out more about how to use this weather script.)</p>
<p>Finally, move <code>weatherrc</code> to your home folder. I recommend renaming it <code>.weatherrc</code>, which will make it invisible to the <code>ls</code> command.</p>
<p>Now, you&#8217;ll need to make sure cygwin knows to look in the bin folder for the weather script. Open the <code>.bash_profile</code> file in your home folder and make sure these lines are included and not commented out:</p>
<blockquote><p>
if [ -d "${HOME}/bin" ] ; then<br />
  PATH=${HOME}/bin:${PATH}<br />
fi
</p></blockquote>
<p>Once you&#8217;ve done all that, type <code>weather</code> into cygwin, and it should give you the forecast and current conditions no matter where you are in the file system.</p>
</li>
</ol>
<h4 id="manage_a_todo_list_todo">Manage a todo list: todo</h4>
<p>Gina Tripani from Lifehacker has started an open source command line <a href="http://ginatrapani.github.com/todo.txt-cli/">todo list manager</a>. Once installed you can type things like <code>todo add "Write blog post"</code> to add an item to your todo list, <code>todo ls</code> to get a list of things to do, and <code>todo do 1</code> to cross off the first thing on the list, and a lot more. </p>
<p>You can find plenty more about the script and how to install it at the link above.</p>
<h4 id="update_twitter_tweet">Update twitter: tweet</h4>
<p>This python script will let you easily send messages to Twitter from the command line. Simply copy and paste <a href="http://snipplr.com/view.php?codeview&amp;id=7870">this code</a> to a text file and save it as tweet.py (ideally in the bin directory you made above). To make it even more convenient, comment out or delete these lines:</p>
<blockquote><p>
user = raw_input(&#8216;Username: &#8216;)<br />
password = raw_input(&#8216;Password: &#8216;)
</p></blockquote>
<p>and replace them with:</p>
<blockquote><p>
user = &#8220;your twitter user name&#8221;<br />
password = &#8220;your twitter password&#8221;
</p></blockquote>
<p>Then open the <code>.bash_profile</code> file again and add this line to the bottom of the file:</p>
<blockquote>
<p>alias tweet=&#8217;tweet.py&#8217;</p>
</blockquote>
<p>Now you can type <code>tweet "Message to send to twitter"</code> to send tweets from the command line.</p>
<h4 id="solve_math_problems_solve">Solve math problems: solve</h4>
<p>This one is easy: simply add the following lines to the end of your <code>.bash_profile</code> file:</p>
<blockquote><p>
function solve () {<br />
    awk &#8220;BEGIN { print $* ; }&#8221;<br />
}
</p></blockquote>
<p>Now you can type <code>solve "2*(3+4)"</code> and it will return 14.</p>
<p>Hope you all find some of these tools useful! If you have any that you want to share, feel free to leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://jdharper.com/blog/command-line-tools-weather-todo-wget-tweet-and-solve/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command Line Tools, Post 0: The Quake-Style Command Line</title>
		<link>http://jdharper.com/blog/command-line-tools-post-0-the-quake-style-command-line/</link>
		<comments>http://jdharper.com/blog/command-line-tools-post-0-the-quake-style-command-line/#comments</comments>
		<pubDate>Sat, 02 May 2009 16:13:56 +0000</pubDate>
		<dc:creator>J. D. Harper</dc:creator>
				<category><![CDATA[autohotkey]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[console2]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I am rediscovering the joys of the command line. After a couple years of service, my laptop was getting sluggish. After the delays finally became intolerable, I ordered a new hard drive and reinstalled my system from scratch. In addition to making the laptop faster, the process has gotten me to reexamine some tools I [...]]]></description>
			<content:encoded><![CDATA[<p>I am rediscovering the joys of the command line. </p>
<p>After a couple years of service, my laptop was getting sluggish. After the delays finally became intolerable, I ordered a new hard drive and reinstalled my system from scratch. In addition to making the laptop faster, the process has gotten me to reexamine some tools I had previously neglected.</p>
<p>Chief among these is Cygwin. Linux has a lot of useful command line tools, and Cygwin makes these tools available for Windows. I use it to get the weather, manage a todo list, download files, do math, and even send updates to Twitter. Why use the command line for these tasks, when there are good graphical ways of doing them? Because it&#8217;s really, really fast.</p>
<p><a href="http://www.jdharper.com/images/FULL-S_20090502_102849_1_1024x768.png"><img src="http://www.jdharper.com/images/SMALL-T_20090502_102849_1_500x375.png" /></a></p>
<p>The command line drops down over my other windows, like a video game console, at the press of a simple keyboard shortcut. Then it&#8217;s just a matter of typing in what I want. </p>
<p>I&#8217;ve written about <a href="http://www.jdharper.com/wordpress/2008/01/04/automated-screenshots-and-quake-style-console-popups-with-autohotkey/">how to set this up before</a>, but a few things have changed since then. Here&#8217;s how to set up a Quake-style dropdown command line.</p>
<ol>
<li>
<p>Install <a href="http://www.cygwin.com/">Cygwin</a>. I use the <a href="http://www.e-texteditor.com/">e text-editor</a>, which automatically installs Cygwin with a bunch of useful packages in order to enable its more advanced features.</p>
</li>
<li>
<p>Install <a href="http://www.autohotkey.com/">AutoHotkey</a>. (By the way, this program has a <em>lot</em> more uses than just this drop-down command line. It&#8217;s something I know I haven&#8217;t explored to its full potential yet.)</p>
</li>
<li>
<p>Install <a href="http://sourceforge.net/project/showfiles.php?group_id=43764">Console2</a>. This is a free and open source console program, which is much prettier than the standard Windows Command Prompt tool. You&#8217;ll want to install the latest beta version of the software (the stable version hasn&#8217;t been updated in <em>years</em>). For reference, I&#8217;m using <a href="http://sourceforge.net/project/downloading.php?group_id=43764&amp;filename=Console-2.00b144-Beta.zip&amp;a=12887926">Beta #144</a>.</p>
</li>
<li>
<p>Download <a href="http://www.jdharper.com/downloads/console.xml">console.xml</a> and <a href="http://www.jdharper.com/downloads/consolecygwin.xml">consolecywgin.xml</a> and put them in the same folder as Console2, replacing the console.xml file that is already there.</p>
</li>
<li>
<p>In the Console2 folder, right click on Console2.exe and click Create Shortcut. Rename it consolecygwin.</p>
</li>
<li>
<p>Right click that shortcut and click Properties. In the &#8220;Target&#8221; field, add <code>-c consolecygwin.xml</code> after the final quotation mark. Click OK.</p>
</li>
<li>
<p>Open Autohotkey if it isn&#8217;t open already. Right-click on the Autohotkey icon in the system tray and click Edit Script.</p>
</li>
<li>
<p>Copy and paste <a href="http://www.jdharper.com/downloads/dropdownconsolescript.txt">the contents of this file</a> to the end of the AutoHotkey.ahk file that appears.</p>
</li>
<li>
<p>Save and close the AutoHotkey.ahk file. Right click the Autohotkey icon and click Reload This Script.</p>
</li>
</ol>
<p>Now if you hit the Windows Key and the ~ key, you&#8217;ll get a regular old DOS prompt. Hit Windows Key + Shift + ~, you&#8217;ll get the Cygwin prompt. Type <code>exit</code> into either prompt to make it go away. Press escape to hide the prompt, and press either of the hotkeys mentioned above to bring it back.</p>
<p>In my next post, I&#8217;ll go into how to set up some of the neat commands I mentioned earlier.</p>
]]></content:encoded>
			<wfw:commentRss>http://jdharper.com/blog/command-line-tools-post-0-the-quake-style-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
