pre-commit hooks which runs the following programs on shell script files:
.pre-commit-config.yaml
example:
- repo: https://github.com/fauust/pre-commit-shell
rev: v1.0
hooks:
- id: shellcheck
args: ["-x"]
- id: shfmt
args: ["-d", "-i", "2", "-ci"]
shfmt and shellcheck tools must be installed separately.
For CI systems or if you don't want to install the tools locally, you can use the docker official images:
- repo: local
hooks:
- id: docker-shell-shellcheck
name: Run shellcheck with docker
language: docker_image
entry: koalaman/shellcheck:stable
types: [shell]
- id: docker-shell-shfmt
name: Run shfmt with docker
entry: mvdan/shfmt:latest -d -i 2 -ci
language: docker_image
types: [shell]