flymake-shellcheck icon indicating copy to clipboard operation
flymake-shellcheck copied to clipboard

A ShellCheck-powered backend for Flymake

flymake-shellcheck

MELPA License

An Emacs (26+) Flymake handler for bash/sh scripts, using ShellCheck. Installing Flymake is not necessary as it is included with Emacs itself.

Installation

First, make sure ShellCheck is installed by following the installation guide. After that, you can install flymake-shellcheck by using the package-install command (make sure MELPA is included in your package sources):

M-x package-install RET flymake-shellcheck RET

Alternatively, you can just add flymake-shellcheck.el to your load-path.

Usage

To enable the Flymake backend whenever a bash or sh script is visited, add the following to your init.el file:

(add-hook 'sh-mode-hook 'flymake-shellcheck-load)

If you're using use-package, try this instead:

(use-package flymake-shellcheck
  :commands flymake-shellcheck-load
  :init
  (add-hook 'sh-mode-hook 'flymake-shellcheck-load))

After opening a shell/sh file, remember to enable Flymake:

M-x flymake-mode RET

Customization

  • You can set the flymake-shellcheck-program variable to the path of the ShellCheck executable in your system, in case executable-find wasn't able to find it automatically.
  • You can set the flymake-shellcheck-use-file variable to nil if you wish to run the syntax checker on the contents of the buffer, rather than the contents of the file on disk (default: t).
  • You can set the flymake-shellcheck-allow-external-files variable to t if you want to allow shellcheck to read external sources (it adds -x as argument, described in the SC1091 docs, default: nil).

License

Distributed under the GNU General Public License, version 3.