Skip to content

Instantly share code, notes, and snippets.

@cgrs
Last active February 12, 2019 13:02
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 cgrs/da7484f5790efc9dea8e774dac08cd61 to your computer and use it in GitHub Desktop.
Save cgrs/da7484f5790efc9dea8e774dac08cd61 to your computer and use it in GitHub Desktop.
[bash 4+] fill .gitignore with popular templates (from GitHub)
#!/bin/bash
function is_present () {
command -v "$1" &>/dev/null
}
if ! is_present curl; then
echo "curl not found"
exit 1
fi
function ignore () {
if ! curl --fail -H "Accept: application/vnd.github.raw" \
"https://api.github.com/gitignore/templates/${1^}" 2>/dev/null; then
(>&2 echo "not found")
fi
}
if test $# -gt 0; then
ignore $1 >> .gitignore
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment