Last active
April 19, 2023 19:36
-
-
Save demonnic/2ea29a12da9b10beae71f83e196e9d5a to your computer and use it in GitHub Desktop.
Script to install or update XCode Command Line Tools. Tested working on MacOS 13.3.1 on 2023-04-19
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
#!/usr/bin/env bash | |
cliLocation="/Library/Developer/CommandLineTools" | |
tmpFile="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress" | |
if [[ ! -d "$cliLocation" ]] | |
then | |
touch $tmpFile | |
fi | |
PROD=$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //') | |
if [[ ! -z $PROD ]] | |
then | |
softwareupdate -i "$PROD" --verbose | |
if [[ -f "$tmpFile" ]] | |
then | |
rm $tmpFile | |
fi | |
else | |
echo "Command Line Tools are up to date" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment