Created
August 1, 2012 06:21
-
-
Save shenqi/3224222 to your computer and use it in GitHub Desktop.
bootstrap.sh
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 zsh | |
if ! test -e /Applications/Xcode.app/; then | |
echo -e "\e[33;1mNeeds Xcode installed. Aborting...\e[m"; | |
open 'macappstore://itunes.apple.com/jp/app/xcode/id497799835?mt=12' && exit 1 | |
fi | |
function check_n_install(){ | |
local com2 com3 | |
if ! test -x $(/usr/bin/which $1); then | |
echo -e "\e[36mInstalling $1...\e[m" | |
if ! test -z $2; then | |
com2=$2' ' | |
else | |
if ! test -z $3; then | |
com3=' '$3 | |
fi | |
com2=''; com3='' | |
fi | |
brew install ${com2}$1${com3} | |
else | |
echo -e "\e[35m$1 already installed. Skipping.\e[m" | |
fi | |
echo '' | |
} | |
if ! test -x $(/usr/bin/which brew); then | |
echo -e "\e[33;1mHomebrew is not installed, start installing\e[m"; | |
echo '/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"' | |
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)" | |
else | |
echo -e "\e[33;1mHomebrew on system. Skipping installation\e[m" | |
fi | |
echo '' | |
echo -e "\e[36mExporting homebrew paths\e[m" | |
echo 'export PATH=/usr/local/bin:/usr/local/sbin:$PATH' | |
export PATH=/usr/local/bin:/usr/local/sbin:$PATH | |
echo '' | |
check_n_install 'git' | |
echo -e "\e[35mUpdating homebrew formulas\e[m" | |
#brew update | |
echo '' | |
echo -e "\e[33;1mDoctoring brew...\e[m" | |
#brew doctor | |
echo '' | |
echo -e "\e[1mCheck the message above. You can abord\e[m \e[33;1mnow\e[m \e[1mby ctrl-c\e[m" | |
echo "If you wish to continue, press enter" | |
read abort | |
echo -e "\e[35mTapping dupes...\e[m" | |
echo 'brew tap homebrew/dupes' | |
brew tap homebrew/dupes | |
echo '' | |
echo -e "\e[33;1mStart installing.\e[m" | |
echo -e "\e[31;1m* Essential Utils *\e[m" | |
check_n_install 'autoconf' | |
check_n_install 'automake' | |
check_n_install 'autoconf' | |
check_n_install 'lv' | |
check_n_install 'wget' '' '--enable-iri' | |
echo -e "\e[31;1m* Shells *\e[m" | |
check_n_install 'zsh' '-f' | |
if test -e /etc/zshenv; then | |
echo -e "\e[1mMoving misconfigured file by Apple.\e[m\e[33;1m Needs superuser permission.\e[m" | |
echo "If you wish to continue, press enter" | |
read cont | |
echo 'sudo mv /etc/zshenv /etc/zprofile' | |
sudo mv /etc/zshenv /etc/zprofile | |
echo '' | |
fi | |
if test -d /usr/local/share/zsh-completions; then | |
check_n_install 'zsh-completions' | |
fi | |
sh_name=$(/usr/bin/which zsh) | |
if ! [ ${sh_name} = $SHELL ] ; then | |
echo -e "\e[33;1mChanging login shell\e[m" | |
echo -e "\e[1mEditing /etc/shells file.\e[m\e[33;1m Needs superuser permission.\e[m" | |
echo $sh_name | pbcopy && echo "'$sh_name' copyed to clipboard" | |
echo "If you wish to continue, press enter" | |
read cont2 | |
echo 'sudo vim /etc/shells' | |
sudo vim /etc/shells | |
chsh -s $sh_name | |
echo '' | |
fi | |
#brew install mercurial | |
#brew install -f vim | |
check_n_install 'screen' '-f' #default screen is not 256-color enabled | |
echo '' | |
echo -e "\e[33;1mInstalling ruby\e[m" | |
ruby_ver='1.9.3-p194' | |
check_n_install 'rbenv' | |
check_n_install 'ruby-build' | |
if ! test -e ~/.zsh/completions/_rbenv; then | |
mkdir -p ~/.zsh/compleions/ | |
curl -L -s -o ~/.zsh/completions/_rbenv https://raw.github.com/sstephenson/rbenv/master/completions/rbenv.zsh | |
echo '' | |
fi | |
if ! [ $(rbenv global)=${ruby_ver} ]; then | |
echo -e "\e[35mInstalling ruby-$ruby_ver...\e[m" | |
echo "rbenv install $ruby_ver" | |
rbenv install $ruby_ver | |
echo 'rbenv rehash' | |
rbenv rehash | |
echo "rbenv global $ruby_ver" | |
rbenv global $ruby_ver | |
else | |
echo -e "\e[35mruby-$ruby_ver already installed. Skipping.\e[m" | |
fi | |
echo '' | |
echo -e "\e[36mExporting ruby executable path for version $ruby_ver\e[m" | |
echo 'export PATH=$HOME/.rbenv/versions/$ruby_ver/bin:$PATH' | |
export PATH=$HOME/.rbenv/versions/$ruby_ver/bin:$PATH | |
echo '' | |
echo -e "\e[35mUpdating rubygems...\e[m" | |
gem update --system | |
gem update | |
echo '' | |
echo -e "\e[33;1mConfiguring perl\e[m" | |
if ! test -x $(/usr/bin/which cpanm); then | |
echo -e "\e[35mInstalling cpan-minus...\e[m \e[33;1m Needs superuser permission.\e[m" | |
echo 'curl -L http://cpanmin.us | perl - --sudo App::cpanminus' | |
curl -L http://cpanmin.us | perl - --sudo App::cpanminus | |
else | |
echo -e "\e[36mcpan-minus already installed. Skipping.\e[m" | |
fi | |
echo '' | |
echo -e "\e[36mExporting perl executable path\e[m" | |
echo 'export PATH=$HOME/.perl5/bin:$PATH' | |
export PATH=$HOME/.perl5/bin:$PATH | |
echo -e "\e[36mConfiguring cpan-minus\e[m" | |
echo 'export PERL_CPANM_OPT="-l ~/.perl5"' | |
export PERL_CPANM_OPT="-l ~/.perl5" | |
echo '' | |
if ! test -e ~/.perl5/lib/perl5/local/lib.pm; then | |
echo -e "\e[35mInstalling local::lib...\e[m" | |
echo 'cpanm local::lib' | |
cpanm local::lib | |
echo '' | |
else | |
echo -e "\e[36mlocal::lib already installed. Skipping.\e[m" | |
fi | |
if ! test -x $(/usr/bin/which cpan-outdated); then | |
echo -e "\e[35mInstalling App::cpanoutdated...\e[m" | |
echo 'cpanm App::cpanoutdated' | |
cpanm App::cpanoutdated | |
else | |
echo -e "\e[36mApp::cpanoutdated already installed. Skipping.\e[m" | |
fi | |
echo -e "\e[35mUpdating cpan modules...\e[m" | |
cpan-outdated | cpanm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment