Created
October 9, 2018 23:08
-
-
Save listrophy/ce316218f89b7835dddbd2f7f919a681 to your computer and use it in GitHub Desktop.
Tell spotlight to ignore node_modules in a subdirectory
This file contains hidden or 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
#!/usr/bin/env bash | |
# Use like: | |
# spotlight_ignore_node_modules.sh ~ | |
PROGNAME=$(basename $0) | |
BASE=${1:-$HOME} | |
red=$(tput setaf 1) | |
green=$(tput setaf 2) | |
yellow=$(tput setaf 3) | |
reset=$(tput sgr0) | |
set -e | |
find $BASE -type d -name 'node_modules' | while read dir; do | |
if [[ $(grep -o "node_modules" <<< "$dir" | grep "" -c) == 1 ]]; then | |
if [ -f "$dir/.metadata_never_index" ]; then | |
echo "${PROGNAME}: ${yellow}$dir already has been ignored ${reset}" | |
else | |
echo "${PROGNAME}: ${green}Adding ignore to $dir ${reset}" | |
touch "$dir/.metadata_never_index" | |
fi | |
fi | |
done | |
# if [ `grep -o "Permission denied" <<< "$dir" | grep "" -c` > 0 ]; then | |
# echo "${PROGNAME}: ${red}Permission denieded for `$dir` ${reset}" | |
# fi | |
echo "${reset}All done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That looks like not working on Catalina.