This is a Sublime Text 3/4 plugin to format your shell scripts using shfmt.
- Format current file/selection(s)
- Format current file on save
- Minify current file
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.
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
.
- 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": ""
},
- Format entire file:
Shfmt: Format file
- Format one or more selections:
Shfmt: Format selection(s)
- Minify entire file:
Shfmt: Minify file
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