Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

format the shell script

Tags:

bash

shell

I have some 1000 lines shell script with all the kepywords

if/else, while, HERE document

Can anyone tell the best way to format the script, so the script looks good.

I was trying VG= in vim but that displaces HERE document content as well.

like image 201
Ajay Singh Avatar asked Sep 18 '25 09:09

Ajay Singh


1 Answers

check this https://github.com/mvdan/sh, here is the sample command for indent with two spaces

shfmt -i 2 -w yourscript

like image 96
Daniel YC Lin Avatar answered Sep 20 '25 23:09

Daniel YC Lin