Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shell (.profile/.bash_profile) script fragment for osx that installs gnu utils using brew
#
# 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
You can’t perform that action at this time.