-
-
Save CatmanIX/5970451 to your computer and use it in GitHub Desktop.
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/sh | |
USAGE="[-l] <types> ..." | |
LONG_USAGE="Generate/Append the repo's .gitignore file using the gitignore.io api | |
-l | |
If no other option is present, list available templates. | |
If options do exist, output is redirected to stdout. | |
`curl -s http://gitignore.io/api/`" | |
SUBDIRECTORY_OK= | |
CHECK= | |
. "$(git --exec-path)/git-sh-setup" | |
while getopts "l" OPTION; do | |
case $OPTION in | |
l) | |
CHECK="yes" | |
;; | |
[?]) | |
usage | |
;; | |
esac | |
done | |
shift $(($OPTIND-1)) | |
if [ $CHECK ]; then | |
if [ $@ ]; then | |
curl -s "http://gitignore.io/api/`printf ',%s' \"$@\" | cut -c 2-`" | |
else | |
curl -s "http://gitignore.io/api/list" | |
fi | |
exit 0 | |
fi | |
if [ $# -eq 0 ]; then | |
usage | |
fi | |
require_work_tree_exists | |
cd_to_toplevel | |
touch .gitignore | |
for arg; do | |
if [ `grep -ic $arg .gitignore` -eq 0 -a $arg != "list" ]; then | |
LIST="$LIST${LIST:+,}$arg" | |
fi | |
done | |
curl -s "http://gitignore.io/api/$LIST" | tee -a .gitignore | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment