-
-
Save andyjeffries/3d55b1272a126393aed5 to your computer and use it in GitHub Desktop.
Fix SM2 Icon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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