Last active
February 3, 2020 07:54
-
-
Save boozook/764f0fc3e7dde7ba67653147029e5ccc to your computer and use it in GitHub Desktop.
[MacOS] TimeMachine Exclude Build Files
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
#!/bin/bash | |
exclude() { | |
THE_NAME=$1 | |
ROOT_DIR=$2 | |
TARGET_FILE=$3 | |
NEAR_DIR=$4 | |
TARGET_DIR=$5 | |
echo "searching build-dirs for $THE_NAME projects where '$NEAR_DIR' near by '$TARGET_FILE' starting from $ROOT_DIR" | |
find $ROOT_DIR -type f -name $TARGET_FILE -exec dirname {} \; 2>/dev/null | while read -r path; do | |
PATH_NEAR_DIR=$path/$NEAR_DIR | |
PATH_TARGET=$path/$TARGET_DIR | |
if [[ -d $PATH_TARGET && -d $PATH_NEAR_DIR ]] && \ | |
[[ "$PATH_TARGET" != *"$PATH_NEAR_DIR/"* && "$PATH_TARGET" != *"$NEAR_DIR/"* ]] && \ | |
[[ "$PATH_TARGET" != *".app"* ]] && \ | |
[[ `tmutil isexcluded "$PATH_TARGET"` == "[Included]"* ]]; | |
then | |
tmutil addexclusion "$PATH_TARGET" | |
echo "- $PATH_TARGET" | |
fi | |
done | |
return 0 | |
} | |
exclude_anyway() { | |
[[ -d $1 ]] && tmutil addexclusion $1 && echo "- $1" | |
} | |
exclude Rust ~/projects "Cargo.toml" target target | |
exclude Node ~/projects "package.json" node_modules node_modules | |
exclude CMake ~/projects "Makefile" CMakeFiles "../bin" | |
exclude CMake ~/projects "CMakeLists.txt" build "build" | |
exclude CMake ~/projects "CMakeLists.txt" bin "bin" | |
# exclude_anyway ~/projects/rls-build | |
exclude_anyway ~/.vscode | |
exclude_anyway ~/.xargo | |
exclude_anyway ~/.npm | |
# Exclude cargo reg & cache: | |
[[ -d ~/.cargo ]] && tmutil addexclusion ~/.cargo/**/* | |
# exclude huge apps: | |
# sudo exclude_anyway /Applications/Xcode.app |
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
#!/bin/bash | |
mdfind com_apple_backup_excludeItem==com.apple.backupd | |
mdfind com_apple_backup_excludeItem==com.apple.backupd -count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment