Skip to content

Instantly share code, notes, and snippets.

@glaszig
Created October 31, 2018 00:47
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 glaszig/23d33c871bc8a52930f076ae7ac85103 to your computer and use it in GitHub Desktop.
Save glaszig/23d33c871bc8a52930f076ae7ac85103 to your computer and use it in GitHub Desktop.
quick and dirty dev setup for macos
#!/usr/bin/env ruby
require 'open3'
ENV["HOMEBREW_NO_AUTO_UPDATE"] = "1"
ENV["HOMEBREW_INSTALL_URL"] ||= "https://raw.githubusercontent.com/Homebrew/install/master/install"
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
def install! cask_name, *cmd
Open3.popen3("which", cask_name.to_s) do |_, stdout, _, thread|
if thread.value.success?
puts " Found at #{stdout.read.chomp}. Skipping."
else
cmd ||= [ :brew, :cask, :install, cask_name ]
system! *cmd
end
end
end
puts "This script will setup a development environment on this Mac."
puts "It will install the following."
puts
puts " * Homebrew"
puts " from #{ENV["HOMEBREW_INSTALL_URL"]}"
puts " which you might want to review for security measures."
puts " * Git"
puts " * VirtualBox"
puts " * Vagrant"
puts
puts "Enter YES to continue. Everything else will stop this script."
exit 1 unless "YES" == gets.chomp
puts
puts ">> Homebrew"
install! :brew, %[ /usr/bin/ruby -e "$(curl -fsSL #{ENV["HOMEBREW_INSTALL_URL"]})" ]
system! %[ brew tap | grep -q "homebrew/tap" || brew tap homebrew/cask ]
puts ">> Git"
install! "git"
puts ">> VirtualBox"
install! "virtualbox"
puts ">> Vagrant"
install! "vagrant"
puts
puts "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment