Shell script formatting and linting with shfmt
Install shfmt per instructions.
shfmt.el is not (yet) on MELPA so install it locally however you like. You will have
to install reformatter
and
flycheck
separately.
Manual formatting requires no configuration; just call shfmt-buffer
or
shfmt-region
. Enable shfmt-on-save-mode
to auto-format on save. Add this to
the sh-mode-hook
to enable automatically in new buffers.
Call flycheck-shfmt-setup
to enable the Flycheck checker.
Using use-package
, assuming
installed locally to lisp/shfmt
:
(use-package shfmt
:ensure nil
:load-path "lisp/shfmt"
:ensure-system-package shfmt
:hook (sh-mode . shfmt-on-save-mode))
(use-package flycheck-shfmt
:ensure nil
:after flycheck
:load-path "lisp/shfmt"
:config
(flycheck-shfmt-setup))
GPL-3