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).
There are two ways to format your code: Automatically format on save (requires enabling in Packages → Format Shell → Toggle Format on Save) Run the command Format Shell: Format to invoke shfmt manually.
Run command go install and installation should start. Once installation is done, through terminal (GitBash or cmd) navigate to $HOME/go/bin (on Windows by default it's under C:\Users\your_username\go\bin) From here you can use the shfmt command like so shfmt -l -w yourBashScript.sh. Voila!
A program that improves the presentation of programming source code. Based on an analysis of the syntax, it indents lines appropriately and squashes extraneous blank spaces and lines in order to produce more readable code.
you can script vim to do: "gg=G" that means "indent all the file"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With