<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Eitan Suez's Home: Open Sesame</title>
    <link>http://u2d.com/articles/2006/01/17/open-sesame</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Open Sesame</title>
      <description>&lt;p&gt;One of the small little but valuable features I used to like on macosx (before switching to Ubuntu last Summer) was the command-line &lt;code&gt;open&lt;/code&gt; command.  You could just type &lt;code&gt;open index.html&lt;/code&gt; and the file would pop up in the a web browser.  I used it all the time.&lt;/p&gt;

&lt;p&gt;I'm not "guru of the universe" and surely something like this exists for linux but for some reason thirty minutes searching the synaptic package manager did not yield anything.&lt;/p&gt;

&lt;p&gt;So one day I finally decided to turn on my brain for a change and in five minutes hacked this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  #!/usr/bin/ruby -w

  def suffix(file_name)
    file_name.split(".").last()
  end

  map = {
           "pdf" =&amp;gt; "kpdf",
           "directory" =&amp;gt; "nautilus",
           "html" =&amp;gt; "epiphany",
           "htm" =&amp;gt; "epiphany",
           "xls" =&amp;gt; "gnumeric",
           "csv" =&amp;gt; "gnumeric",
           "txt" =&amp;gt; "kate",
           "gif" =&amp;gt; "eog",
           "jpg" =&amp;gt; "eog",
           "png" =&amp;gt; "eog",
           "xml" =&amp;gt; "gedit"
         }

  file_name = ARGV[0]
  key = (File.directory?(file_name)) ? "directory" : suffix(file_name)
  app_name = map[key]

  fork do
    puts "invoking #{app_name}..\n"
    exec "#{app_name} #{file_name}"
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I've been using it daily for a while now and I like it.  Over time I've built myself a few other little utilities.  A recent one is merge for merging data with an erb template.  I use 'show' a lot.  It breaks down a path-like structure into multiple line entries so one can actually read the foresaken string.  I use it like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  eitan@ubuntu:~/bin$ show path
  PATH:
  /usr/local/bin
  /usr/local/sbin
  /sbin
  /usr/sbin
  /bin
  /usr/bin
  ...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;.. or &lt;code&gt;show classpath&lt;/code&gt; etc..&lt;/p&gt;

&lt;p&gt;Another one that is a real time saver when the time comes to import a new project into subversion is &lt;code&gt;svnize&lt;/code&gt; which will automatically restructure your project in the trunk/tags/branches hierarchy suitable for doing the import. &lt;/p&gt;</description>
      <pubDate>Tue, 17 Jan 2006 16:38:59 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:b1eef7a2b667d4ab90ca99ab442fcf58</guid>
      <author>eitan</author>
      <link>http://u2d.com/articles/2006/01/17/open-sesame</link>
      <category>Programming</category>
      <category>Linux</category>
    </item>
  </channel>
</rss>
