Skip to content

Instantly share code, notes, and snippets.

@twcamper
Last active August 22, 2019 18:40
Show Gist options
  • Save twcamper/3261288 to your computer and use it in GitHub Desktop.
Save twcamper/3261288 to your computer and use it in GitHub Desktop.
Add executables to .gitignore
#! /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