shfmt

Updated: 21 February 2025

A shell program formatter https://github.com/mvdan/sh

Check a shell program and specify 4 spaces of indentation

shfmt -i 4 my-bash-script.sh

Show a diff between actual and desired formatting

shfmt -d my-bash-script.sh

Directly update the file being checked

shfmt -w my-bash-script.sh

Leave a comment