Skip to content

Instantly share code, notes, and snippets.

@mpapis
Last active December 27, 2015 21:29
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 mpapis/7391753 to your computer and use it in GitHub Desktop.
Save mpapis/7391753 to your computer and use it in GitHub Desktop.
Install CLT if not yet installed, for OSX 10.9+
osx_109_install_clt()
{
typeset __developer_update
# continue if already using some xcode
xcode-select -p >/dev/null 2>&1 && return 0 || true
# trick the update to think user opened the dialog
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
# find pending update
__developer_update="$(
softwareupdate -l 2>/dev/null |
awk -F'*' '/Command Line Developer Tools/{print last_line} {last_line=$2}'
)"
# remove white-space from the name
__developer_update="${__developer_update# }"
# run the update or clean the trick file
if [[ -n "${__developer_update}" ]]
then sudo softwareupdate -i "${__developer_update}" -v || return $?
else 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