Created
July 25, 2016 16:29
-
-
Save josePhoenix/736a1817b4cd1d43c7afc3aafc628ea5 to your computer and use it in GitHub Desktop.
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
| #!/bin/bash | |
| set -ue | |
| NEW_BREW_PREFIX="local" | |
| if [[ $PATH == */usr/stsci/*ssb* ]] | |
| then | |
| echo "There's an SSB environment activated (ssbdev, ssbx, or ssbrel)." | |
| echo "Things could go unpredictably if this script were to continue. Try running without a Ureka / SSB environment activated." | |
| exit 1 | |
| fi | |
| if [[ $(which ruby) != "/usr/bin/ruby" ]] | |
| then | |
| echo "Ruby wasn't found in the default location. Perhaps you've customized things?" | |
| exit 1 | |
| fi | |
| cd | |
| destination="$HOME/$NEW_BREW_PREFIX/homebrew" | |
| if [ -d $destination ]; | |
| then | |
| echo "There's already something in $destination" | |
| echo "Remove $HOME/$NEW_BREW_PREFIX to get a fresh start" | |
| exit 1 | |
| fi | |
| echo "Copying the Homebrew package manager into $destination" | |
| git clone https://github.com/Homebrew/homebrew.git $destination | |
| mkdir -p "$HOME/$NEW_BREW_PREFIX/bin" \ | |
| "$HOME/$NEW_BREW_PREFIX/share/man/man1" \ | |
| "$HOME/$NEW_BREW_PREFIX/etc" | |
| ln -s "$HOME/$NEW_BREW_PREFIX/homebrew/bin/brew" \ | |
| "$HOME/$NEW_BREW_PREFIX/bin/brew" | |
| ln -s "$HOME/$NEW_BREW_PREFIX/homebrew/share/man/man1/brew.1" \ | |
| "$HOME/$NEW_BREW_PREFIX/share/man/man1/brew.1" | |
| export PATH="$HOME/$NEW_BREW_PREFIX/bin:$PATH" | |
| brew --version | |
| brew tap homebrew/homebrew-science | |
| echo " | |
| setenv _old_PATH \"$PATH\" | |
| setenv PATH \"\$HOME/$NEW_BREW_PREFIX/bin:\$PATH\" | |
| setenv _old_MANPATH \"$MANPATH\" | |
| setenv MANPATH \"\$HOME/$NEW_BREW_PREFIX/share/man:\$MANPATH\"" > "$HOME/$NEW_BREW_PREFIX/bin/brew_activate.csh" | |
| echo " | |
| setenv PATH \$_old_PATH | |
| unsetenv _old_PATH | |
| setenv MANPATH \$_old_MANPATH | |
| unsetenv _old_MANPATH" > "$HOME/$NEW_BREW_PREFIX/bin/brew_deactivate.csh" | |
| echo | |
| echo | |
| echo "***** Install complete *****" | |
| echo | |
| echo "If you use tcsh/csh (the default at the Institute), add an alias | |
| to ~/.cshrc: | |
| alias brew_activate \"source $HOME/$NEW_BREW_PREFIX/bin/brew_activate.csh\" | |
| alias brew_deactivate \"source $HOME/$NEW_BREW_PREFIX/bin/brew_deactivate.csh\" | |
| If you use bash (the default everywhere else), add a function | |
| to ~/.bash_profile: | |
| brew_activate() { | |
| export _old_PATH=\"\$PATH\" | |
| export PATH=\"\$HOME/$NEW_BREW_PREFIX/bin:\$PATH\" | |
| export _old_MANPATH=\"\$MANPATH\" | |
| export MANPATH=\"\$HOME/$NEW_BREW_PREFIX/share/man:\$MANPATH\" | |
| } | |
| brew_deactivate() { | |
| export PATH=\"\$_old_PATH\" | |
| unset _old_PATH | |
| export MANPATH=\"\$_old_MANPATH\" | |
| unset _old_MANPATH | |
| } | |
| Then, open a new shell. Type 'brew_activate' to add Homebrew to the path. | |
| You can add brew_activate to the end of your shell rc file (.bashrc, | |
| .bash_profile, or .cshrc) to ensure the 'brew' command is always available." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment