Mix formatter plugin for Bash scripts and sigils.
Formats .sh and .bash files, as well as ~BASH and ~b sigils in Elixir code.
Configuration
Add to your .formatter.exs:
[
plugins: [Bash.Formatter],
inputs: [
"{mix,.formatter}.exs",
"{config,lib,test}/**/*.{ex,exs}",
"scripts/**/*.{sh,bash}"
],
# Optional Bash formatter configuration
bash: [
indent_style: :spaces, # :spaces or :tabs
indent_width: 2, # number of spaces (ignored if :tabs)
line_length: 100 # max line length before wrapping
]
]Formatting Behavior
- Preserves shebang lines exactly as-is
- Normalizes indentation based on configuration
- Wraps long lines after operators (
|,&&,||) with backslash continuation - Never breaks inside strings, heredocs, arrays, or comments
- Preserves existing backslash continuations
- Graceful degradation: returns input unchanged on parse errors