Last active
December 23, 2020 20:38
-
-
Save 100ideas/1f5c1cc87d8d313c227d373086ad7a44 to your computer and use it in GitHub Desktop.
recursively Spotlight-ignore or delete node_modules folders
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 | |
# delete node_modules folder recursively from a specified path using command line | |
# taken from https://stackoverflow.com/questions/42950501/delete-node-modules-folder-recursively-from-a-specified-path-using-command-line | |
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' + |
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
#!/usr/bin/env bash | |
# bash script for ignoring all files in node_modules for Spotlight | |
# | |
# this will add ignore to all node_moduless in ~ for Spotlight | |
# | |
# Usage: | |
# ./node-add-ignore.sh [path] | |
# Options: path Path to start looking for node_modules [default: $HOME] | |
# | |
# https://github.com/Willian-Zhang/Ignore-node_modules-in-Spotlight | |
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