Skip to content

Instantly share code, notes, and snippets.

@christopher-hopper
Last active December 20, 2015 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christopher-hopper/6052008 to your computer and use it in GitHub Desktop.
Save christopher-hopper/6052008 to your computer and use it in GitHub Desktop.
Generate a `.gitattributes` file
#
# Find text files with this command
#
grep -r -m 1 "^" . \
| grep -v "^Binary file" \
| gawk 'BEGIN { FS=":" } { print $1 }' \
| sed -re 's:.+\.([^\.]+)$:*.\1 text eol=lf:g' -e '/\//d' \
| sort -u
#
# Find binary files with this command
#
grep -r -m 1 "^" . \
| grep "^Binary file" \
| sed -re 's:^Binary\sfile\s(.*)\smatches:\1:g' -e 's:.+\.([^\.]+)$:*.\1 binary:g' -e '/\//d' \
| sort -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment