Last active
August 22, 2019 18:40
-
-
Save twcamper/3261288 to your computer and use it in GitHub Desktop.
Add executables to .gitignore
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 sh | |
# GNU or BSD find: | |
# "-perm +111" == any write bits of file mode are set | |
# "-type f" == regular file | |
# | |
# "grep -v" == invert result, i.e., filter out files under '.git' | |
# "sed 's/^\.\///g')`" == trim initial ./ from all paths | |
for path in `find . -perm +111 -type f | grep -vE "\.(git|rb$|sh$)" | sed 's/^\.\///g')` | |
do | |
# Is the path NOT listed? | |
# (i.e does grep return null or empty string?) | |
if test -z `grep -E ^$path$ .gitignore` | |
then | |
echo adding \'$path\' to .gitignore | |
echo $path >> .gitignore | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment