Created
September 12, 2016 06:36
-
-
Save bfg/000799dd89a40f8d0b480561db101523 to your computer and use it in GitHub Desktop.
Shell (.profile/.bash_profile) script fragment for osx that installs gnu utils using brew
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
# | |
# shell dot-profile fragment | |
# | |
is_osx() { | |
test "$(uname -s)" = "Darwin" | |
} | |
check_is_osx() { | |
if ! is_osx; then | |
echo "This function is supported only Mac OS X." | |
return 1 | |
fi | |
return 0 | |
} | |
homebrew_install_brew() { | |
check_is_osx || return 1 | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
} | |
homebrew_install_gnu_utils() { | |
check_is_osx || return 1 | |
brew install --with-default-names gnu-getopt coreutils pcre findutils gnu-sed homebrew/dupes/grep | |
} | |
homebrew_set_up() { | |
check_is_osx || return 1 | |
#echo "setting brew vars." 1>&2 | |
if [ -e "/usr/local/bin/readlink" ]; then | |
echo "Looks like you don't have readlink installed; type the following:" | |
echo "" | |
echo " sudo ln -s /usr/local/bin/greadlink /usr/local/bin/readlink" | |
echo "" | |
fi | |
PATH="/usr/local/opt/gnu-getopt/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/findutils/bin:/usr/local/opt/gettext/bin:/usr/local/opt/grep/bin:/usr/local/bin:$PATH" | |
export PATH | |
} | |
# this fragment is valid only on OS X | |
is_osx && homebrew_set_up | |
# vim:shiftwidth=2 softtabstop=2 expandtab | |
# EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment