Last active
December 27, 2015 21:29
-
-
Save mpapis/7391753 to your computer and use it in GitHub Desktop.
Install CLT if not yet installed, for OSX 10.9+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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