Skip to content

Instantly share code, notes, and snippets.

@andyjeffries
Created December 20, 2011 08:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyjeffries/3d55b1272a126393aed5 to your computer and use it in GitHub Desktop.
Save andyjeffries/3d55b1272a126393aed5 to your computer and use it in GitHub Desktop.
Fix SM2 Icon
#!/usr/bin/env ruby
require 'base64'
require 'FileUtils'
SCRIPT_NAME = File.basename(__FILE__)
if ARGV.size == 1
puts "Amending script to include #{ARGV[0]} as the icon..."
icon_data = ""
File.open(ARGV[0], "rb") do |f|
icon_data = f.read
end
encoded_data = Base64.encode64(icon_data)
script = File.read(__FILE__)
script.gsub(/__END__.*/msi, '')
script << "\n\n__END__\n"
script << encoded_data
File.open(__FILE__, "w") do |f|
f << script
end
puts "Done"
else
abort "No icon found, please specify one using '#{SCRIPT_NAME} whatever.icns'" unless Object::const_defined?(:DATA)
puts "Replacing icon in Sublime Text 2..."
encoded_data = DATA.read
icon_data = Base64.decode64(encoded_data)
File.open("/Applications/Sublime Text 2.app/Contents/Resources/Sublime Text 2.icns", "wb") do |newFile|
newFile << icon_data
end
puts "Done"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment