Skip to content

Instantly share code, notes, and snippets.

@qwinters
Created January 23, 2022 12:55
Show Gist options
  • Save qwinters/25df11f1d8602fe9adae4d18f169c6c6 to your computer and use it in GitHub Desktop.
Save qwinters/25df11f1d8602fe9adae4d18f169c6c6 to your computer and use it in GitHub Desktop.
Better integration for homebrew for Mac
# Add brew sbin to path
[[ $PATH != *"/usr/local/sbin"* ]] && export PATH=/usr/local/sbin:$PATH
# Wrapper for brew to execute brewfile dumping on certain brew commands
function brew () {
local dump_commands=("install" "uninstall" "tap" "untap")
local main_command="${1}"
local brewfile_path="~/.config/brewfile/Brewfile"
command brew ${@}
for command in "${dump_commands[@]}"; do
[[ "${command}" == "${main_command}" ]] && brew bundle dump --file="$brewfile_path" --force
done
}
# Replace stupid bsd based mac os tools with proper unix versions from brew
[[ $PATH != *"/usr/local/opt/gnu-time"* ]] && export PATH="/usr/local/opt/gnu-time/libexec/gnubin:$PATH"
[[ $PATH != *"/usr/local/opt/grep"* ]] && export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
[[ $PATH != *"/usr/local/opt/coreutils"* ]] && export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment