-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb916e8
commit 3489754
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>action</key> | ||
<false/> | ||
<key>category</key> | ||
<string>SCRIPTS</string> | ||
<key>command</key> | ||
<string>ruby install_dmg.rb</string> | ||
<key>escapequery</key> | ||
<true/> | ||
<key>escapequerybackquotes</key> | ||
<true/> | ||
<key>escapequerybrackets</key> | ||
<true/> | ||
<key>escapequeryquotes</key> | ||
<true/> | ||
<key>escapequerysemicolons</key> | ||
<true/> | ||
<key>growloutput</key> | ||
<true/> | ||
<key>growloutputsticky</key> | ||
<false/> | ||
<key>keyword</key> | ||
<string>dmg</string> | ||
<key>logging</key> | ||
<false/> | ||
<key>silent</key> | ||
<true/> | ||
<key>subtitle</key> | ||
<string>Finds the most recent .dmg file in the downloads folder and automatically installs the app inside of it. Then delets the .dmg file.</string> | ||
<key>title</key> | ||
<string>Install DMG</string> | ||
</dict> | ||
</plist> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'fileutils' | ||
require 'pathname' | ||
include FileUtils | ||
|
||
#go to downloads directory | ||
puts "installing most recent .dmg" | ||
cd File.expand_path("~/Downloads/") | ||
path = Pathname.new('.') | ||
|
||
#find most recent .dmg file | ||
files = path.entries.collect { |file| path+file }.sort { |file1,file2| file1.ctime <=> file2.ctime } | ||
files.reject! { |file| ((file.file? and file.to_s.include?(".dmg")) ? false : true) } | ||
last_dmg = files.last | ||
|
||
#if there is no .dmg file then reject this. | ||
if !last_dmg | ||
puts "No DMG files" | ||
exit | ||
end | ||
|
||
puts "Mounting #{last_dmg}" | ||
|
||
mount_point = Pathname.new "/Volumes/#{last_dmg}" | ||
|
||
result = `hdiutil attach -mountpoint #{mount_point} #{last_dmg}` | ||
|
||
#find any apps in the mounted dmg | ||
files = mount_point.entries.collect { |file| mount_point+file } | ||
files.reject! { |file| ((file.to_s.include?(".app")) ? false : true) } | ||
|
||
files.each { |app| | ||
puts "Copying #{app} to Applications folder" | ||
`cp -a #{app} /Applications/` | ||
} | ||
|
||
#unmount the .dmg | ||
puts "Unmounting #{last_dmg}" | ||
result = `hdiutil detach #{mount_point}` | ||
puts "Finished installing #{last_dmg}" | ||
|
||
|
||
#delete the .dmg | ||
rm last_dmg |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>creator</key> | ||
<string>Christian Schlensker</string> | ||
<key>website</key> | ||
<string>http://cswebartisan.com</string> | ||
</dict> | ||
</plist> |