For bash
and sh
, there is shfmt
.
How do I format zsh
code?
I'd like to be able to set some options like in shfmt
, ie:
-i uint indent: 0 for tabs (default), >0 for number of spaces
-bn binary ops like && and | may start a line
-ci switch cases will be indented
-sr redirect operators will be followed by a space
-kp keep column alignment paddings
-fn function opening braces are placed on a separate line
zsh-hist
says it supports "uniform code formatting", but I can't work out how to run it from the command line and it's main purpose is history manipulation.
How do I format zsh
code either in the shell or via something like VSCode prettier?
zsh
code without writing a tool from scratch. – Goggleshfmt
as a base, and create from this your own formatter? Since zsh and bash are syntactically quite similar in spirit, this should be much less work than starting from scratch. – Blotto