Introducing show-syntax: A bat-inspired Syntax Highlighter for PowerShell
Tired of reading raw file dumps in the terminal? show-syntax brings bat-style ANSI syntax highlighting to PowerShell — colour-coded output for PS1, …
Read more →A PowerShell cat-with-syntax-highlighting module inspired by bat — displays file contents with ANSI colour-coded highlighting, optional line numbers, and pipeline support.
show-syntax is a PowerShell module inspired by the popular Rust CLI tool bat — a cat clone with ANSI syntax highlighting. It reads files and outputs their contents to the console with colour-coded highlighting based on file extension, plus optional line numbers and full pipeline support.
Whether you’re reviewing a config file, scanning a script, or paging through log output, show-syntax makes the terminal a much more readable place.
Install from the PowerShell Gallery:
# Install for current user
Install-Module -Name show-syntax -Scope CurrentUser
# Import
Import-Module show-syntax
Requirements: PowerShell 5.1 or later (Windows PowerShell 5.1 and PowerShell 7+).
# Display a PowerShell script with syntax highlighting
Show-Syntax -Path .\Deploy.ps1
# Display a JSON file with line numbers
Show-Syntax -Path .\appsettings.json -ShowLineNumbers
# Pipe multiple files from Get-ChildItem
Get-ChildItem -Path .\src -Filter *.ps1 -Recurse | Show-Syntax -ShowLineNumbers
-ShowLineNumbers-Language when auto-detection isn’t enoughFileInfo objects directlyStreamReader to handle large files without loading everything into memoryShow-SyntaxDisplays the contents of one or more files with ANSI syntax highlighting.
| Parameter | Type | Required | Description |
|---|---|---|---|
-Path | string[] | ✅ | One or more file paths. Accepts pipeline input by value or by property name (FullName, FilePath). |
-ShowLineNumbers | switch | ❌ | Prepends each output line with its 1-based line number. |
-Language | string | ❌ | Overrides auto-detection. See supported language keys below. |
| Key(s) | File types |
|---|---|
ps1, powershell | PowerShell (.ps1, .psm1, .psd1) |
json | JSON |
xml | XML |
md, markdown | Markdown |
py, python | Python |
js, javascript, ts, typescript | JavaScript / TypeScript |
yaml | YAML |
sh, bash | Shell / Bash |
css | CSS / SCSS / Less |
html | HTML |
csv | CSV |
log | Log files |
txt | Plain text (no highlighting) |
Show-Syntax -Path .\Deploy.ps1
Automatically detects the .ps1 extension and applies PowerShell highlighting — keywords, variables, strings, comments, and cmdlet names are all coloured.
Show-Syntax -Path .\appsettings.json -ShowLineNumbers
Displays the file with JSON highlighting (keys, values, booleans, numbers) and prepends each line with its line number.
Get-ChildItem -Path .\src -Filter *.ps1 -Recurse | Show-Syntax -ShowLineNumbers
Pipes all .ps1 files found recursively under .\src into Show-Syntax, displaying each with a header banner, PowerShell highlighting, and line numbers.
Show-Syntax -Path .\Dockerfile -Language sh
Forces Shell/Bash highlighting on a file whose extension is unknown to the auto-detector.
'.\README.md' | Show-Syntax
Passes a file path string through the pipeline and displays it with Markdown highlighting.
Contributions are welcome! See the GitHub repository for details.
show-syntax is released under the MIT License.