-
-
Save TorgeH/4b9b0c0eee1b0b1a7ac81761faa3c772 to your computer and use it in GitHub Desktop.
GNU-ize Mac OS X El Capitan
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/bash | |
PROFILE_FILE=$HOME/.bash_profile | |
PATH_FILE=$HOME/.bash_path | |
# 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 -n 'export PATH="/usr/local/sbin' > $PATH_FILE | |
# Build PATH variable script in ~/.bash_path | |
for i in /usr/local/Cellar/*/*/bin /usr/local/Cellar/*/*/libexec/gnubin; do | |
echo -n ":${i//://}" >> $PATH_FILE | |
done | |
#finalize PATH variable (adding back the old PATH, if exists, and closing the qoutes) | |
echo -e '${PATH+:}$PATH"\n' >> $PATH_FILE | |
#start the MANPATH | |
echo -n 'export MANPATH="' >> $PATH_FILE | |
# build the contents of MANPATH, the closing quote needs to be within the sed statement | |
# even with "echo -n" we we would have an additional line-break otherwise | |
for i in /usr/local/Cellar/*/*/share/man /usr/local/Cellar/*/*/libexec/gnuman; do | |
echo -n "$i:" | |
done | sed 's#:$#${MANPATH+:}$MANPATH"#' >> $PATH_FILE | |
# Check if .bash_path is being called from .bash_profile, if not, rebuild it from scratch | |
if grep -qE "([$]HOME|~)/\.bash_path" $PROFILE_FILE; then | |
# nothing to do -- .bash_profile already sources .bash_path | |
else | |
[ -e "$PROFILE_FILE" ] && mv $PROFILE_FILE $(mktemp ${PROFILE_FILE}.XXXX) | |
# Add Ubuntu-style PS1 to .bash_profile | |
cat <<EOF > $PROFILE_FILE | |
alias ll="ls -ahl --color=always" | |
export PS1="\[\033[1;32m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]# " | |
[ -f $PATH_FILE ] && source $PATH_FILE | |
EOF | |
fi |
Some change is done on Revisions · GNU-ize Mac OS X El Capitan. Apart from the bug fix, there're also some cosmetic change, e.g. the .bash_path
is now more readable; through printf instead of echo.
Note: I original forked this as another gist, and now imported it to a repository in https://github.com/ickc/GNU-ize
Sadly GitHub doesn't show that it is a fork of this gist. Credits will be given to the original author in the README. @TorgeH: do you have any license you'd want to use? If no I'd just choose GPLv3 (appropriate because this script is about GNU).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report:
./gnuize.sh: line 37: syntax error near unexpected token `else'