Skip to content

Instantly share code, notes, and snippets.

@ardeidae
Created February 17, 2020 21:07
Show Gist options
  • Save ardeidae/71a1e2e1dbe04fb19320710022b98ef3 to your computer and use it in GitHub Desktop.
Save ardeidae/71a1e2e1dbe04fb19320710022b98ef3 to your computer and use it in GitHub Desktop.
headless install of xcode command line tools
#!/bin/bash
# headless install of xcode command line tools
if ! xcode-select -p &> /dev/null; then
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
CLTX=$(softwareupdate --list | \
grep "\*.*Command Line Tools" | \
tail -n 1 | \
awk -F"Label: " '{print $2}' \
)
softwareupdate --verbose --install "$CLTX"
rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment