I'm currently setting up Neovim and want to know about useful tools for linting and formatting Bash scripts. So far, I've only gotten bashls and Neovim diagnostics that use shellcheck working. I'm hoping to find a way for the diagnostics to display code warnings like "SCXXXX" as virtual text to avoid searching for them manually.
I've heard about tools like beautysh and prettier, but I'm curious if they're as developed as similar tools in other programming languages. Since my experience is limited to Bash, I wonder if these tools are as beneficial for shell scripting or if the nature of scripting makes them less useful. Any suggestions for tools, no matter how small, would be greatly appreciated, especially as I'm new to this and have only used a basic Neovim setup without the industry-standard editors like VS Code.
3 Answers
Definitely check out ShellCheck! It works great with bashls and can help you catch a lot of errors. It's super useful, especially if you're running scripts that will go into CI/CD pipelines. It'll make your life much easier!
When it comes to one-off scripts, I mostly rely on syntax highlighting in my editor. If it's a bigger project or something that’s critical, I really advise using shellcheck to lint your scripts. It saves a ton of hassle later!
I've learned that the hard way! Using shellcheck up front really helps avoid those late-night debugging sessions.
For formatting, you should look at shfmt from mvdan. It's a solid formatter specifically for shell scripts and works great with shellcheck. Combined, they can really streamline your workflow!
Totally agree! ShellCheck is essential if you're doing anything serious with bash.