Skip to content

Instantly share code, notes, and snippets.

@mrinalwadhwa
Created January 19, 2016 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrinalwadhwa/5d4b462ba40e229617ee to your computer and use it in GitHub Desktop.
Save mrinalwadhwa/5d4b462ba40e229617ee to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
is_xcode_cli_tools_installed() {
xcode-select -p >/dev/null 2>&1
[[ $? -eq 0 ]]
}
install_xcode_cli_tools() {
local flag='/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
touch $flag
local UPDATE_NAME=$( softwareupdate --list \
| grep '\*.*Command Line' \
| head -n 1 \
| awk -F"*" '{print $2}' \
| sed -e 's/^ *//' \
| tr -d '\n'
)
softwareupdate --install --verbose "${UPDATE_NAME}"
local success=$?
rm $flag
return $success
}
main() {
is_xcode_cli_tools_installed || install_xcode_cli_tools
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment