Last active
September 25, 2021 23:30
-
-
Save noize-e/d8cae0995b99015680f556c1532395a1 to your computer and use it in GitHub Desktop.
Create and manage the .gitignore file
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
#!/usr/bin/env bash | |
set -o errexit | |
_FILES_RULES=('.DS_Store' 'node_modules ' '.jekyll-cache' '.sass-cache' '.venv' 'venv') | |
_USAGE="$(printf """ | |
Git .gitignore file helper tool. | |
Usage: ignore (filepath) ([OPTIONS]) | |
Create new file in the current working directory | |
Pre-defined rules include in the file: | |
.DS_Store | |
node_modules | |
.jekyll-cache | |
.sass-cache | |
.venv | |
venv | |
Filepath: | |
Add new file path rule into the file. | |
Options: | |
-h: Show help | |
-p: Display all rules in the file. | |
""")" | |
if [[ -z "${1}" ]]; then | |
find . -name '*.DS_Store*' -print -delete && \ | |
touch .gitignore | |
for rule in "${_FILES_RULES[@]}" | |
do | |
echo "${rule}" >> .gitignore | |
done | |
exit 0 | |
fi | |
case "${1}" in | |
-h ) | |
echo -e "${_USAGE}" | |
exit 0 | |
;; | |
-p ) | |
cat .gitignore | |
exit 0 | |
;; | |
*) echo "${1}" >> .gitignore ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Git
.gitignore
file helper.Usage
.gitignore
file with pre-defined rules.>_ ignore
>_ ignore {file/parh.ext}