Skip to content

Instantly share code, notes, and snippets.

@hangyan
Last active October 4, 2015 10:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hangyan/c0d7c450ee6ec68177a4 to your computer and use it in GitHub Desktop.
Save hangyan/c0d7c450ee6ec68177a4 to your computer and use it in GitHub Desktop.
check tools installed via brew on mac
function brew_check() {
brew $2 info $1 | grep -q "Not installed"
}
function brew_install() {
tool=$(echo $1 | awk '{print $1}')
cask=$(echo $1 | awk '{print $2}')
brew_check $tool $cask
[[ $? -eq 0 ]] && echo -e "Installing $tool..." && brew $cask install $tool
}
function brew_cask_install() {
brew_check $1
[[ $? -eq 0 ]] && echo -e "Installing $1..." && brew cask install $1
}
function brew_check_all() {
tools=('pgcli' 'npm' 'markdown' 'thefuck' 'fish' \
'httpie' 'jq' 'icdiff' 'htop-osx' 'mtr' 'cmake' \
'zsh' 'p7zip' 'svn' 'python' 'git' 'launchrocket cask')
for i in $tools; do
echo "Checking $i..."
brew_install $i
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment