Skip to content
Browse files

added bin/open (for ubuntu)

  • Loading branch information...
1 parent 6d9d75c commit 14b445167f71bb2c3844c02c874ca30546602d5a Yutaka HARA committed May 7, 2012
Showing with 31 additions and 0 deletions.
  1. +31 −0 tools/open
View
31 tools/open
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+
+def sh(cmd)
+ puts cmd
+ system cmd
+end
+
+if ARGV.size == 0
+ puts "usage: #$0 file"
+else
+ path = ARGV[0]
+ case File.extname(path).downcase[1..-1]
+ when "png", "jpg", "gif"
+ sh "pqiv -i '#{path}' &"
+ when "xls", "xlsx", "ods"
+ sh "oocalc '#{path}' &"
+ when "doc", "docx", "odt"
+ sh "oowriter '#{path}' &"
+ when "pdf"
+ sh "acroread '#{path}' &"
+ when "html"
+ sh "chromium-browser '#{path}' &"
+ else
+ if File.directory?(path)
+ sh "nautilus #{path} &"
+ else
+ $stderr.puts "don't know how to open #{path} (#{File.extname(path)})"
+ exit 1
+ end
+ end
+end

0 comments on commit 14b4451

Please sign in to comment.
Something went wrong with that request. Please try again.