Last active
October 4, 2015 10:02
-
-
Save hangyan/c0d7c450ee6ec68177a4 to your computer and use it in GitHub Desktop.
check tools installed via brew on mac
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
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