Last active
October 17, 2018 15:14
-
-
Save tlnagy/18a190c62a4ddf187e49 to your computer and use it in GitHub Desktop.
This small script uses Homebrew to make your OS X machine more Linux-like by adding the GNU variants of many command line tools to your PATH. You will need Xcode's command line tools and homebrew installed. Also you'll need to quit and re-initialize your shell to see the changes.
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
#! /bin/sh | |
# Copyright (c) 2014, Tamas Nagy <tamas at tamasnagy dot com> | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are met: | |
# | |
# 1. Redistributions of source code must retain the above copyright notice, | |
# this list of conditions and the following disclaimer. | |
# | |
# 2. Redistributions in binary form must reproduce the above copyright notice, | |
# this list of conditions and the following disclaimer in the documentation | |
# and/or other materials provided with the distribution. | |
# | |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
# POSSIBILITY OF SUCH DAMAGE. | |
# Inspired by http://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/ | |
if command -v brew >/dev/null 2>&1; then | |
echo "Brew installed! Let's go" | |
else | |
echo "Homebrew needs to be in your path. See http://brew.sh/" | |
exit 1; | |
fi | |
taps=`brew tap` | |
if [[ $taps =~ .*dupes.* ]] | |
then | |
echo "Dupes already tapped" | |
else | |
brew tap homebrew/dupes | |
fi | |
if [[ ! -s "$HOME/.bash_profile" && -s "$HOME/.zshrc" ]] ; then | |
profile_file="$HOME/.zshrc" | |
else | |
profile_file="$HOME/.bash_profile" | |
fi | |
if ! grep -q '/libexec/gnubin' "${profile_file}" ; then | |
echo "Editing ${profile_file} to have /libexec/gnubin in the path" | |
echo '# Prefer GNU tools over the default OS X ones' | |
echo 'export PATH="$(brew --prefix coreutils)/libexec/gnubin:/usr/local/bin:$PATH"' >> "${profile_file}" | |
fi | |
brew install coreutils | |
brew install binutils | |
brew install diffutils | |
brew install ed --default-names | |
brew install findutils --default-names | |
brew install gawk | |
brew install gnu-indent --default-names | |
brew install gnu-sed --default-names | |
brew install gnu-tar --default-names | |
brew install gnu-which --default-names | |
brew install gnutls --default-names | |
brew install grep --default-names | |
brew install gzip | |
brew install screen | |
brew install watch | |
brew install wdiff --with-gettext | |
brew install wget | |
brew install nano |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment