Last active
July 10, 2020 18:35
-
-
Save woudsma/07741ef9c2ce760883e0ff34bf072da9 to your computer and use it in GitHub Desktop.
gitignore command line function
This file contains hidden or 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
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