Skip to content

purcell/emacs-shfmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Melpa Status Melpa Stable Status Build Status Support me

shfmt.el

This Emacs library provides commands and a minor mode for easily reformatting shell script source code using the shfmt program.

Installation

If you choose not to use one of the convenient packages in MELPA, you'll need to add the directory containing shfmt.el to your load-path, and then (require 'shfmt).

Usage

Customise the shfmt-command variable as desired, then call shfmt-buffer or shfmt-region as convenient.

Enable shfmt-on-save-mode in Shell Mode buffers like this:

(add-hook 'sh-mode-hook 'shfmt-on-save-mode)

or locally to your project with a form in your .dir-locals.el like this:

((sh-mode
   (mode . shfmt-on-save)))

You might like to bind shfmt or shfmt-buffer to a key, e.g. with:

(define-key 'sh-mode-map (kbd "C-c C-f") 'shfmt)

💝 Support this project and my other Open Source work

💼 LinkedIn profile

✍ sanityinc.com

🐦 @sanityinc

About

Reformat shell script code in Emacs using shfmt

Resources

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •