Install OSX Command Line Tools without using the GUI

Running xcode-select –install will trigger the standard gui interface confirming download, etc.  So trying this over an ssh connection will note be possible.

StackExchange to the rescue!

 

1
2
3
4
5
6
7
8
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
PROD=$(softwareupdate -l |
  grep "\*.*Command Line" |
  head -n 1 | awk -F"*" '{print $2}' |
  sed -e 's/^ *//' |
  tr -d '\n')
softwareupdate -i "$PROD" --verbose
rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress