if [[ $OSTYPE == msys2 || $OSTYPE == cygwin ]]; then
shopt -s completion_strip_exe
fi
When they git commit, pre-commit will auto run shftm -w for all shell files except zsh files:
[INFO] Initializing environment for https://github.com/Freed-Wu/sh.
[INFO] Installing environment for https://github.com/Freed-Wu/sh.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
shfmt.........................................................................Failed
- hook id: shfmt
- files were modified by this hook
Now your bash file has be changed to
if [[ $OSTYPE == msys2 || $OSTYPE == cygwin ]]; then
shopt -s completion_strip_exe
fi
You must git add the_changed_bash_file, then git commit:
Refer https://pre-commit.com/#golang
Usage:
Shell developers can create a file named
.pre-commit-config.yaml
in their repos:Then enable
pre-commit
bypre-commit install
.Then if they write a code like this:
When they
git commit
,pre-commit
will auto runshftm -w
for all shell files except zsh files:Now your bash file has be changed to
You must
git add the_changed_bash_file
, thengit commit
:Now it is OK.
I think it will be useful for shell developers.
And if you merge this change, remember Publish a new version, because
Only download the shfmt of v3.6.0, which don't contain a pre-commit-hook.