Created
January 10, 2017 02:29
-
-
Save takaokouji/dedacae2a177cf8b984cf1d0de659a10 to your computer and use it in GitHub Desktop.
MacBookセットアップスクリプト
This file contains hidden or 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 | |
BREWFILE_DIR = '~/local/etc' | |
module StringAsk | |
refine String do | |
def ask? | |
print("#{self}? [y/N] ") | |
if /y|yes|t|true/i =~ gets.chomp | |
return true | |
else | |
return false | |
end | |
end | |
alias_method '_?', 'ask?' | |
end | |
end | |
using StringAsk | |
def bash(command) | |
`/bin/bash --login -c '#{command}'` | |
end | |
if 'Xcode'._? | |
`xcode-select --install` | |
end | |
if 'Homebrew'._? | |
eval(`curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install`) | |
`brew doctor` | |
`brew tap caskroom/cask` | |
end | |
if "execute brew bundle(#{BREWFILE_DIR})"._? | |
`brew tap Homebrew/bundle` | |
Dir.chdir(File.expand_path(BREWFILE_DIR)) do | |
`brew bundle --verbose` | |
end | |
`brew linkapps` | |
end | |
if 'anyenv'._? | |
`git clone https://github.com/riywo/anyenv ~/.anyenv` | |
File.open(File.expand_path('~/.bash_profile'), 'a') do |f| | |
f.puts('export PATH="$HOME/.anyenv/bin:$PATH"') | |
f.puts('eval "$(anyenv init -)"') | |
end | |
end | |
if 'rbenv (anyenv)'._? | |
bash('anyenv install rbenv') | |
`git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.anyenv/envs/rbenv/plugins/rbenv-gem-rehash` | |
latest_version = bash('rbenv install -l | grep -v - | tail -1').strip | |
bash("rbenv install #{latest_version}") | |
end | |
if 'Spacemacs'._? | |
`git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment