Skip to content

Instantly share code, notes, and snippets.

@earlonrails
Forked from yoneken/remove_CLI_tools.sh
Last active December 27, 2015 19:19
Show Gist options
  • Save earlonrails/7376526 to your computer and use it in GitHub Desktop.
Save earlonrails/7376526 to your computer and use it in GitHub Desktop.
# remove_CLI_tools.sh
# written by cocoanetics:http://www.cocoanetics.com/2012/07/you-dont-need-the-xcode-command-line-tools/
# modified by yoneken
# modified by earlonrails
#!/bin/sh
DEV_SDK_RECEIPT_FILE=/var/db/receipts/com.apple.pkg.DevSDKLeo.bom
DEV_SDK_RECEIPT_PLIST=/var/db/receipts/com.apple.pkg.DevSDKLeo.plist
CLANG_RECEIPT_FILE=/var/db/receipts/com.apple.pkg.clangLeo.bom
CLANG_RECEIPT_PLIST=/var/db/receipts/com.apple.pkg.clangLeo.plist
GCC_RECEIPT_FILE=/var/db/receipts/com.apple.pkg.gcc4.2Leo.bom
GCC_RECEIPT_PLIST=/var/db/receipts/com.apple.pkg.gcc4.2Leo.plist
LLVM_RECEIPT_FILE=/var/db/receipts/com.apple.pkg.llvm-gcc4.2Leo.bom
LLVM_RECEIPT_PLIST=/var/db/receipts/com.apple.pkg.llvm-gcc4.2Leo.plist
DEV_TOOLS_RECEIPT_FILE=/var/db/receipts/com.apple.pkg.DeveloperToolsCLILeo.bom
DEV_TOOLS_RECEIPT_PLIST=/var/db/receipts/com.apple.pkg.DeveloperToolsCLILeo.plist
if [ ! -f "$DEV_TOOLS_RECEIPT_FILE" ]
then
echo "Command Line Tools not installed."
exit 1
fi
echo "Command Line Tools installed, removing ..."
# Need to be at root
cd /
for BOM_FILE in $DEV_SDK_RECEIPT_FILE $CLANG_RECEIPT_FILE $GCC_RECEIPT_FILE $LLVM_RECEIPT_FILE $DEV_TOOLS_RECEIPT_FILE
do
lsbom -fls $BOM_FILE | sudo xargs -I{} rm -r "{}"
sudo rm $BOM_FILE
done
# remove the plist files
sudo rm $DEV_SDK_RECEIPT_PLIST $CLANG_RECEIPT_PLIST $GCC_RECEIPT_PLIST $LLVM_RECEIPT_PLIST $DEV_TOOLS_RECEIPT_PLIST
echo "Done! Please restart XCode to have Command Line Tools appear as uninstalled."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment