MacRuby : http://subtech.g.hatena.ne.jp/cho45/20110523/1306125053 をMacRubyに置き換えた
#!/usr/local/bin/macruby
framework "Cocoa"
ary = [
"com.apple.Safari",
"com.google.Chrome",
"org.mozilla.firefox",
"com.operasoftware.Opera" ]
ary.each_with_index do |item, i|
puts "[#{i}] : #{item}"
end
puts "Plese chose a browser"
print "> "
num = STDIN.gets.to_i
raise if (num < 0 || num >= ary.size )
ret1 = LSSetDefaultHandlerForURLScheme("http", ary[num])
ret2 = LSSetDefaultHandlerForURLScheme("https", ary[num])
puts "set default browser to #{ary[num]}" if (ret1 == 0 && ret2 == 0)