Installing xCode Command Line Tools through Terminal without any user interaction

Most people suggest using the xcode-select command when installing xCode’s Command Line Tools through terminal. This works fine, except it shows a UI-popup where you have to confirm the download. I’m currently writing a script to set up my Mac and found out I could install the Command Line tools without any user interaction using the following commands:

touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
sudo softwareupdate -i -a

The explanation? When running xcode-select for the first time, OSX creates a file in /tmp to notify softwareupdate it should show the additional developer-tools. When running softwareupdate -i -a you’re saying that you want to install all available software updates, including the developer tools. When manually creating the file in /tmp using touch you bypass the UI confirmation.

comments powered by Disqus