Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install Xcode CLI Tools without GUI
# See
echo "Checking Xcode CLI tools"
# Only run if the tools are not installed yet
# To check that try to print the SDK path
xcode-select -p &> /dev/null
if [ $? -ne 0 ]; then
echo "Xcode CLI tools not found. Installing them..."
touch /tmp/;
PROD=$(softwareupdate -l |
grep "\*.*Command Line" |
head -n 1 | awk -F"*" '{print $2}' |
sed -e 's/^ *//' |
tr -d '\n')
softwareupdate -i "$PROD" -v;
echo "Xcode CLI tools OK"
Copy link

jaygooby commented Apr 11, 2022

Thanks for this! Had same issue of needing to install over ssh over vpn, so no chance to get at the GUI (also had to remove the -v)

Copy link

I tested the version from @That-Dude and it works under my VM of Big Sur 11.5.2. Catalina 10.15.3 fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment