Home

Awesome

AltSH formatter (experimental)

The altshfmt is an experimental tool for formatting AltSH (alternative shell script) with extended syntax that cannot be formatted correctly by shfmt. This is implemented as a wrapper for shfmt.

Currently supported syntax: ShellSpec, shpec

Use it at your own risk

Requirements

How to use

Since altshfmt is implemented as compatible as possible with shfmt, You can use it instead of the shfmt command.

Linux or macOS

Windows

WSL (Windows 10, version 1803 and later) or busybox-w32 is required. To run it from Windows (instead of from WSL), run altshfmt.bat instead of altshfmt.

WSL

busybox-w32

Using with VSCode

Use the shell-format (github) extension.

About syntax detection

The syntax is automatically determined from the beginning and ending pairs of the block of DSL used in the shell script.

shell directive

If you have problems with the automatic detection, you can also use the shell directive. The shell directive is a comment that begins with "shell:".

Example

#!/bin/sh
# shell: sh altsh=shellspec

Describe
  ...
End

Usage: shell: [<shell>] [altsh=<syntax>]

Limitation

altshfmt is several times slower than shfmt.