Skip to content

Instantly share code, notes, and snippets.

@woudsma
Last active July 10, 2020 18:35
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 woudsma/07741ef9c2ce760883e0ff34bf072da9 to your computer and use it in GitHub Desktop.
Save woudsma/07741ef9c2ce760883e0ff34bf072da9 to your computer and use it in GitHub Desktop.
gitignore command line function
function gitignore() {
TAGS="${@}"
TAGS="${TAGS/mac/macos}"
GITIGNORE_IO_URL="https://www.toptal.com/developers/gitignore/api/${TAGS// /,}"
GITIGNORE_FILE="$(pwd)/.gitignore"
echo "--> Fetching: $GITIGNORE_IO_URL"
echo "--> Writing: $GITIGNORE_FILE"
curl -fsSL "$GITIGNORE_IO_URL" >> "$GITIGNORE_FILE"
}
# - Installation:
# 1. Add the gitignore function above into your ~/.zshrc or ~/.bash_profile file
# 2. Reload your config by opening a new terminal, or by typing:
# $ source ~/.zshrc
# - Usage:
# $ cd ~/Projects/my-project
# $ gitignore node mac
# $ --> Fetching: https://www.toptal.com/developers/gitignore/api/node,macos
# $ --> Writing: /Users/username/Projects/my-project/.gitignore
# $ cat .gitignore
# # Created by https://www.toptal.com/developers/gitignore/api/node
# # Edit at https://www.toptal.com/developers/gitignore?templates=node
# ### Node ###
# # Logs
# logs
# *.log
# npm-debug.log*
# yarn-debug.log*
# yarn-error.log*
# lerna-debug.log*
## etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment