mirror of
https://github.com/tiyn/dotfiles.git
synced 2026-06-04 09:01:36 +02:00
Shell: Added gitinore creation script
This commit is contained in:
161
.config/gitignore/python
Normal file
161
.config/gitignore/python
Normal file
@@ -0,0 +1,161 @@
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/venv,python
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
#Pipfile.lock
|
||||
|
||||
# poetry
|
||||
#poetry.lock
|
||||
|
||||
# pdm
|
||||
#pdm.lock
|
||||
.pdm.toml
|
||||
|
||||
# PEP 582
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
#.idea/
|
||||
|
||||
### Python Patch ###
|
||||
poetry.toml
|
||||
|
||||
# ruff
|
||||
.ruff_cache/
|
||||
|
||||
# LSP config files
|
||||
pyrightconfig.json
|
||||
|
||||
### venv ###
|
||||
[Bb]in
|
||||
[Ii]nclude
|
||||
[Ll]ib
|
||||
[Ll]ib64
|
||||
[Ll]ocal
|
||||
[Ss]cripts
|
||||
pyvenv.cfg
|
||||
pip-selfcheck.json
|
||||
136
.local/bin/etc/gitignore
Executable file
136
.local/bin/etc/gitignore
Executable file
@@ -0,0 +1,136 @@
|
||||
#!/bin/sh
|
||||
|
||||
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/gitignore"
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage:
|
||||
gitignore TEMPLATE...
|
||||
Create a new .gitignore from templates.
|
||||
|
||||
gitignore -f TEMPLATE...
|
||||
Overwrite existing .gitignore.
|
||||
|
||||
gitignore --add TEMPLATE...
|
||||
Append templates to existing .gitignore.
|
||||
|
||||
gitignore --list
|
||||
List available templates.
|
||||
|
||||
gitignore --show TEMPLATE
|
||||
Show a template.
|
||||
|
||||
Templates are searched in:
|
||||
$CONFIG_DIR
|
||||
EOF
|
||||
}
|
||||
|
||||
list_templates() {
|
||||
[ -d "$CONFIG_DIR" ] || exit 0
|
||||
|
||||
find "$CONFIG_DIR" -type f -exec basename {} \; | sort
|
||||
}
|
||||
|
||||
show_template() {
|
||||
file="$CONFIG_DIR/$1"
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "Unknown template: $1" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat "$file"
|
||||
}
|
||||
|
||||
append_template() {
|
||||
template="$1"
|
||||
file="$CONFIG_DIR/$template"
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "Unknown template: $template" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
{
|
||||
echo
|
||||
echo "# --- $template ---"
|
||||
cat "$file"
|
||||
} >> .gitignore
|
||||
}
|
||||
|
||||
create_gitignore() {
|
||||
mode="$1"
|
||||
shift
|
||||
|
||||
if [ -f .gitignore ] && [ "$mode" != "force" ]; then
|
||||
echo ".gitignore already exists." >&2
|
||||
echo "Use -f to overwrite or --add to append." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
: > .gitignore
|
||||
|
||||
for template in "$@"; do
|
||||
append_template "$template"
|
||||
done
|
||||
}
|
||||
|
||||
add_templates() {
|
||||
[ -f .gitignore ] || touch .gitignore
|
||||
|
||||
for template in "$@"; do
|
||||
append_template "$template"
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
--help|-h)
|
||||
usage
|
||||
;;
|
||||
|
||||
--list)
|
||||
list_templates
|
||||
;;
|
||||
|
||||
--show)
|
||||
shift
|
||||
|
||||
[ $# -eq 1 ] || {
|
||||
echo "--show requires exactly one template" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
show_template "$1"
|
||||
;;
|
||||
|
||||
--add)
|
||||
shift
|
||||
|
||||
[ $# -gt 0 ] || {
|
||||
echo "No templates specified" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
add_templates "$@"
|
||||
;;
|
||||
|
||||
-f)
|
||||
shift
|
||||
|
||||
[ $# -gt 0 ] || {
|
||||
echo "No templates specified" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
create_gitignore force "$@"
|
||||
;;
|
||||
|
||||
"")
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
create_gitignore normal "$@"
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user