Skip to content

Instantly share code, notes, and snippets.

@noize-e
Last active September 25, 2021 23:30
Show Gist options
  • Save noize-e/d8cae0995b99015680f556c1532395a1 to your computer and use it in GitHub Desktop.
Save noize-e/d8cae0995b99015680f556c1532395a1 to your computer and use it in GitHub Desktop.
Create and manage the .gitignore file
#!/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
@noize-e
Copy link
Author

noize-e commented Sep 25, 2021

Git .gitignore file helper.

Usage

  1. Create the .gitignore file with pre-defined rules.
>_ ignore
  1. Add new rule
>_ ignore {file/parh.ext}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment