Skip to content

Instantly share code, notes, and snippets.

@clayfreeman
Last active October 3, 2018 06:14
Show Gist options
  • Save clayfreeman/2a5e54577bcc033e2f00 to your computer and use it in GitHub Desktop.
Save clayfreeman/2a5e54577bcc033e2f00 to your computer and use it in GitHub Desktop.
GNU-ize Mac OS X El Capitan
#!/bin/bash
# Install required packages from Homebrew
brew tap homebrew/dupes
brew install coreutils binutils diffutils ed findutils gawk gnu-indent gnu-sed \
gnu-tar gnu-which gnutls grep gzip screen watch wdiff wget bash gdb gpatch \
m4 make nano file-formula git less openssh python rsync svn unzip vim \
--default-names --with-default-names --with-gettext --override-system-vi \
--override-system-vim --custom-system-icons
brew cleanup
# Empty the .bash_path file that holds GNU paths
echo 'export PATH="/usr/local/sbin:$PATH"' > ~/.bash_path
# Build PATH variable script in ~/.bash_path
for i in /usr/local/Cellar/*/*/bin; do
echo 'export PATH="'$i':$PATH"' >> ~/.bash_path
done
for i in /usr/local/Cellar/*/*/libexec/gnubin; do
echo 'export PATH="'$i':$PATH"' >> ~/.bash_path
done
for i in /usr/local/Cellar/*/*/share/man; do
echo 'export MANPATH="'$i':$MANPATH"' >> ~/.bash_path
done
for i in /usr/local/Cellar/*/*/libexec/gnuman; do
echo 'export MANPATH="'$i':$MANPATH"' >> ~/.bash_path
done
# Check if .bash_path is being called from .bash_profile
PATCH=`grep "~/.bash_path" ~/.bash_profile`
if [ "$PATCH" == "" ]; then
# Add Ubuntu-style PS1 to .bash_profile
cat <<EOF > ~/.bash_profile
alias ll="ls -ahl --color=always"
export PS1="\[\033[1;32m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]# "
EOF
# Add .bash_path to .bash_profile
echo "source ~/.bash_path" >> ~/.bash_profile
fi
@ickc
Copy link

ickc commented Oct 10, 2016

It currently will override my bash profile:

cat <<EOF > ~/.bash_profile

Can you changed it to

cat <<EOF >> ~/.bash_profile

@ickc
Copy link

ickc commented Oct 3, 2018

FYI, I import this to a repository in https://github.com/ickc/GNU-ize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment