A PowerShell module inspired by the popular Rust CLI tool bat — a cat clone with ANSI syntax highlighting. show-syntax reads files and outputs their contents to the console with colour-coded highlighting based on file extension, plus optional line numbers.
- 🎨 ANSI syntax highlighting for common file types: PowerShell, JSON, XML, Markdown, Python, JavaScript/TypeScript, YAML, Shell scripts, CSS, HTML, CSV, and log files
- 🔢 Optional line numbers with
-ShowLineNumbers - 🔧 Language override with
-Languagewhen auto-detection isn't enough - 📥 Pipeline support — pipe paths or
FileInfoobjects directly - 🛡️ Graceful error handling for missing or invalid paths
- ⚡ Efficient streaming — reads files line-by-line via
StreamReaderto handle large files without loading everything into memory
show-syntax is published to the PowerShell Gallery.
# Install from PowerShell Gallery
Install-Module -Name show-syntax -Scope CurrentUser
# Import the module
Import-Module show-syntaxRequirements: PowerShell 5.1 or later (Windows PowerShell 5.1 and PowerShell 7+).
Show-Syntax -Path .\Deploy.ps1Automatically detects the .ps1 extension and applies PowerShell highlighting (keywords, variables, strings, comments, and cmdlet names are all coloured).
Show-Syntax -Path .\appsettings.json -ShowLineNumbersDisplays 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 -ShowLineNumbersPipes 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 shForces Shell/Bash highlighting on a file whose extension is unknown.
'.\README.md' | Show-SyntaxPasses a file path string through the pipeline and displays it with Markdown 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) |
The module includes a Pester 5 test suite.
# Install Pester if not already installed
Install-Module Pester -MinimumVersion 5.0 -Scope CurrentUser -Force
# Run all tests
Invoke-Pester -Path .\show-syntax.Tests.ps1 -Output DetailedContributions are welcome! Please open an issue or pull request on GitHub.