Skip to content
Prettify or Minify bash / posix / mksh script with Sublime Text 3
Python
Branch: master
Clone or download
Latest commit 4b224e5 Jan 25, 2020

README.md

Pretty Shell

Shell Script beautifier plugin for Sublime Text 3.

Recommended for shell scripting beginners.

I've written this plugin for myself to learn how to write scripts in correct syntax.
Highly recommended to use this plugin with:

Dependency

Make sure you have installed shfmt as this package utilizes the formatter.
If you are on macOS, you can install it with Homebrew:

brew install shfmt

If installed via brew and your shell recognize its path, that's it.
Otherwise, install the command in a way whatever you like, then specify full path to the bin in setting:

"shfmt_bin_path": "FULL PATH to shfmt"

Install

  1. Package Control: Install Package
  2. Type PrettyShell and Install
  3. You're ready

Install (Manually on macOS / Linux / Windows)

  1. Quit Sublime Text
  2. Clone this repository as shown below
  3. You're ready
git clone https://github.com/aerobounce/Sublime-Pretty-Shell.git "$HOME/Library/Application Support/Sublime Text 3/Packages/PrettyShell"
  • It should work on Linux / Windows too. Follow the same steps with the equivalent clone target directory.

Usage

  1. Command Palette...
  2. Pretty Shell: Format

or just save script file you are editing while pretty_on_save is true.

Key Binding

Default Key Binding

  • macOS: cmd + ctrl + s
  • Linux: alt + ctrl + s
  • Windows: alt + ctrl + s

Options

"simplify": true, // Simplify the code
"language": "bash", // Language variant to parse (bash / posix / mksh)
"indent": 4, // 0 for tabs
"binop": false, // Binary operators such as '&&' and '|' may start a line
"switchcase": true, // Indent switch cases
"rediop": true, // Redirect operators will be followed by a space
"align": false, // Keep column alignment paddings
"minify": false, // Minify program to reduce its size
"pretty_on_save": true,
"shfmt_bin_path": "shfmt"

Todo

  • Show parsing errors
  • Format only selection

Special Thanks

You can’t perform that action at this time.