bashcommand-linecode-formatting

Code formatter / beautifier for bash (in command line)?


Looking for a command line code formatter that can be used for bash code. It must be configurable and preferably usable from command line.

I have a big project in bash, which I need to use Q in mind for. So far I am happy with a program written in python by Paul Lutus (a remake of his previous version in Ruby).

See http://arachnoid.com/python/beautify_bash_program.html (also cloned here https://github.com/ewiger/beautify_bash).

but I would like to learn any serious alternative to this tool if it exists. Requirements: it should provide robust enough performance and behavior of treating/parsing rather complicated code.

PS I believe full parsing of bash code is generally complicated because there exists no official language grammar (but please correct me if I am wrong about it).


Solution

  • you can script vim to do: "gg=G" that means "indent all the file"