Created
March 7, 2017 05:52
-
-
Save pearofducks/53dd9bae8ba4a6f0a82d507a926c8130 to your computer and use it in GitHub Desktop.
hands-off macOS command-line-tools install
This file contains hidden or 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
if [[ $(/usr/bin/xcode-select -p &>/dev/null; /bin/echo $?) == 2 ]]; then | |
cmd_line_tools_temp_file="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress" | |
touch "$cmd_line_tools_temp_file" | |
cmd_line_tools=$(softwareupdate -l | awk '/\*\ Command Line Tools/ { $1=$1;print }' | tail -1 | sed 's/^[[ \t]]*//;s/[[ \t]]*$//;s/*//' | cut -c 2-) | |
softwareupdate -i "$cmd_line_tools" --verbose | |
if [[ $(/usr/bin/xcode-select -p &>/dev/null; /bin/echo $?) != 2 ]]; then | |
echo "CLT installed." | |
if [[ -f "$cmd_line_tools_temp_file" ]]; then | |
rm "$cmd_line_tools_temp_file" | |
fi | |
else | |
die "CLT install failed" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment