Skip to content

Instantly share code, notes, and snippets.

@komagata
Created June 29, 2011 01:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komagata/1052723 to your computer and use it in GitHub Desktop.
Save komagata/1052723 to your computer and use it in GitHub Desktop.
Make symlink from Mac GUI Apps.
#!/usr/bin/env ruby
require 'fileutils'
def e(path) path.gsub(/[ ()]/) {|s| "\\#{s}"} end
FileUtils.rm_rf("#{ENV['HOME']}/.macapp")
FileUtils.mkdir("#{ENV['HOME']}/.macapp")
Dir.glob('/Applications/{,Utilities/}*.app') do |path|
script = "#{ENV['HOME']}/.macapp/#{path.split('/').last}"
open(script, 'w') {|f| f.write(<<-EOS) }
#!/bin/sh
open -a #{e(path)}
EOS
FileUtils.chmod(0755, script)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment