<?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>mitch&#039;s meanderings &#187; Linux</title>
	<atom:link href="http://mitchcontla.com/category/tech/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://mitchcontla.com</link>
	<description>thoughts on life, technology, and running; links, photos, and videos</description>
	<lastBuildDate>Wed, 19 May 2010 04:58:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Nautilus Script: Edit Remote Files (SSH) with Vim</title>
		<link>http://mitchcontla.com/2007/09/06/nautilus-script-edit-remote-files-ssh-with-vim/</link>
		<comments>http://mitchcontla.com/2007/09/06/nautilus-script-edit-remote-files-ssh-with-vim/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 08:11:41 +0000</pubDate>
		<dc:creator>mitch</dc:creator>
				<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[gvim]]></category>
		<category><![CDATA[nautilus]]></category>
		<category><![CDATA[nautilus-script]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://mitch.contlafamily.com/2007/09/06/nautilus-script-edit-remote-files-ssh-with-vim/</guid>
		<description><![CDATA[My on again, off again love affair with KDE is currently off (but that&#8217;s another story). I&#8217;m once again enjoying the simplicity of Gnome, and the elegance of Nautilus.

The ability to graphically browse remote servers via SSH is great, but I found out that trying to edit a remote file chokes Vim. Apparently the netrw [...]]]></description>
			<content:encoded><![CDATA[<p>My on again, off again love affair with <a href="http://www.kde.org/" title="K Desktop Environment"><span class="caps">KDE</span></a> is currently off (but that&#8217;s another story). I&#8217;m once again enjoying the simplicity of <a href="http://www.gnome.org/" title="Gnome Desktop">Gnome</a>, and the elegance of <a href="http://www.gnome.org/projects/nautilus/" title="Nautilus file manager">Nautilus</a>.</p>

<p>The ability to graphically browse remote servers via <acronym title="secure shell">SSH</acronym> is great, but I found out that trying to edit a remote file chokes <a href="http://www.vim.org/" title="Vim editor">Vim</a>. Apparently the netrw module does not handle an <span class="caps">SSH </span><acronym title="Uniform Resource Identifier">URI</acronym>, but rather prefers <acronym title="secure copy">SCP</acronym>. So a quick nautilus-script to the rescue.</p>

<pre class="code python"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>, <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib</span>
&nbsp;
files = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> unescape<span style="color: black;">&#40;</span>uri<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\s</span>'</span>, r<span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\</span> '</span>, <span style="color: #dc143c;">urllib</span>.<span style="color: black;">unquote</span><span style="color: black;">&#40;</span>uri<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #008000;">file</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">getenv</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;NAUTILUS_SCRIPT_SELECTED_URIS&quot;</span>, <span style="color: #008000;">None</span><span style="color: black;">&#41;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: black;">&#41;</span>:
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">match</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^file://'</span>, <span style="color: #008000;">file</span><span style="color: black;">&#41;</span>:
        files.<span style="color: black;">append</span><span style="color: black;">&#40;</span>unescape<span style="color: black;">&#40;</span><span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^file://'</span>, r<span style="color: #483d8b;">&quot;&quot;</span>, <span style="color: #008000;">file</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">match</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^ssh://'</span>, <span style="color: #008000;">file</span><span style="color: black;">&#41;</span>:
        files.<span style="color: black;">append</span><span style="color: black;">&#40;</span>unescape<span style="color: black;">&#40;</span><span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^ssh://([^/]+)(/[^/]+){2}/(.*)$'</span>, r<span style="color: #483d8b;">'scp://<span style="color: #000099; font-weight: bold;"></span>/<span style="color: #000099; font-weight: bold;"></span>'</span>, <span style="color: #008000;">file</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> files:
    <span style="color: #dc143c;">os</span>.<span style="color: black;">system</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;gvim &quot;</span><span style="color: #483d8b;">&quot;&quot;</span> + <span style="color: #483d8b;">&quot; &quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>files<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
&nbsp;</pre>

<p>Still some work to do, but for now it&#8217;s simple and effective.</p>]]></content:encoded>
			<wfw:commentRss>http://mitchcontla.com/2007/09/06/nautilus-script-edit-remote-files-ssh-with-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash: It&#8217;s the little things</title>
		<link>http://mitchcontla.com/2007/06/27/bash-its-the-little-things/</link>
		<comments>http://mitchcontla.com/2007/06/27/bash-its-the-little-things/#comments</comments>
		<pubDate>Wed, 27 Jun 2007 19:47:50 +0000</pubDate>
		<dc:creator>mitch</dc:creator>
				<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[gnu]]></category>
		<category><![CDATA[hints]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://mitch.contlafamily.com/2007/06/27/bash-its-the-little-things/</guid>
		<description><![CDATA[The Bash shell always amazes me. I needed to create a Maildir using the typical Maildir/cur, Maildir/new, Maildir/tmp structure and stumbled on this:



$ mkdir -m 0700 -p Maildir/{cur,new,tmp}



The -m and -p options are no-brainers, but the {cur,new,tmp} was new to me. It was easy to figure out what was going to happen&#8230; one command to [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.gnu.org/software/bash/" title="Bash - GNU Project">Bash</a> shell always amazes me. I needed to create a <a href="http://en.wikipedia.org/wiki/Maildir" title="Wikipedia: Maildir">Maildir</a> using the typical <code>Maildir/cur</code>, <code>Maildir/new</code>, <code>Maildir/tmp</code> structure and stumbled on this:</p>



<pre class="example"><code>$ mkdir -m 0700 -p Maildir/{cur,new,tmp}</code></pre>



<p>The <code>-m</code> and <code>-p</code> options are no-brainers, but the <code>{cur,new,tmp}</code> was new to me. It was easy to figure out what was going to happen&#8230; one command to create the Maildir directory, and the three subdirectories, I was simply unfamiliar with the syntax. A quick look at the <a href="http://www.gnu.org/software/bash/" title="Bash - GNU Project">Bash</a> man page and I discovered <a href="http://www.gnu.org/software/bash/manual/bashref.html#SEC27" title="Bash Reference Manual: Brace Expansion">Brace Expansion</a>:</p>

<blockquote>Brace expansion is a mechanism by which arbitrary strings may be generated.</blockquote>

<p>A comma separated list between opening and closing braces is expanded by the shell including any preamble (in my case Maildir/) or postscript. Brace expansion can also generate ranges:</p>



<pre class="example"><code>$ echo {1..10}
1 2 3 4 5 6 7 8 9 10</code></pre>



<p>Cool, huh?</p>]]></content:encoded>
			<wfw:commentRss>http://mitchcontla.com/2007/06/27/bash-its-the-little-things/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
