Skip to content

Instantly share code, notes, and snippets.

@stes
Last active March 27, 2021 01:19
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 stes/2fd256e462dbb8fdb9ac7a947ba86217 to your computer and use it in GitHub Desktop.
Save stes/2fd256e462dbb8fdb9ac7a947ba86217 to your computer and use it in GitHub Desktop.
Download .gitignore templates from https://github.com/github/gitignore
#!/bin/bash
# Download gitignore files from https://github.com/github/gitignore
# Example Usage: ./gitignore.sh Python Java > .gitignore
invalid_language() {
>&2 echo "No gitignore found for $1."
return 1
}
echo_header() {
echo "## gitignore for ${1}"
echo "## Source: ${2}"
}
for language in $@; do
url="https://raw.githubusercontent.com/github/gitignore/master/${language}.gitignore"
wget -q --spider "$url" || invalid_language "${language}" || continue
echo_header "$language" "$url"
wget -q -O- "$url"
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment