Skip to content

Sublime Text 3/4 plugin to format your shell scripts using shfmt.

License

Notifications You must be signed in to change notification settings

soifou/sublime-shfmt

Repository files navigation

Shfmt (Shell formatter)

This is a Sublime Text 3/4 plugin to format your shell scripts using shfmt.

Features

  • Format current file/selection(s)
  • Format current file on save
  • Minify current file

Requirements

Obviously shfmt, you can install it in many ways :

apt install shfmt
pacman -Sy shfmt
brew install shfmt

And so on, I'm sure if you are here you already have it.

Installation

Not available on Package Control at the moment.

  • Open Command Palette: <kbd>Package Control: Add Repository</kbd>
  • Add https://github.com/soifou/sublime-shfmt
  • Reopen Command: <kbd>Package Control: Install Package</kbd>
  • Search for sublime-shfmt

Or git clone this repository directly in your sublime Packages/ folder. Usually ~/.config/sublime-text/Packages.

Configuration

  • Look at default values here Preferences > Package Settings > Shfmt > Settings - Default.
  • Edit your user configuration file via Preferences > Package Settings > Shfmt > Settings - User.
  • Override needed values.

If shfmt is available in your $PATH environment, you don't need to set a value paths

"paths": {
    "linux": "",
    "osx": "",
    "windows": ""
},

Else add manually the folder where shfmt live. For instance, if shfmt live in ~/.bin/shfmt, add the following value:

"paths": {
    "linux": "~/.bin",
    "osx": "",
    "windows": ""
},

Usage

Command Palette

Format entire file:
Shfmt: Format file
Format one or more selections:
Shfmt: Format selection(s)
Minify entire file:
Shfmt: Minify file

Hotkeys

Entire file:

  • Linux: alt+f
  • OS X: ctrl+f
  • Windows: alt+f

Selection(s):

  • Linux: alt+shift+f
  • OS X: ctrl+shift+f
  • Windows: alt+shift+f

Or add a custom key bindings using the following commands:

  • shfmt
  • shfmt_selection
  • shfmt_minify

About

Sublime Text 3/4 plugin to format your shell scripts using shfmt.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages