PsBash.Transpiler 0.10.5

dotnet add package PsBash.Transpiler --version 0.10.5
                    
NuGet\Install-Package PsBash.Transpiler -Version 0.10.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PsBash.Transpiler" Version="0.10.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PsBash.Transpiler" Version="0.10.5" />
                    
Directory.Packages.props
<PackageReference Include="PsBash.Transpiler" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PsBash.Transpiler --version 0.10.5
                    
#r "nuget: PsBash.Transpiler, 0.10.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PsBash.Transpiler@0.10.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PsBash.Transpiler&version=0.10.5
                    
Install as a Cake Addin
#tool nuget:?package=PsBash.Transpiler&version=0.10.5
                    
Install as a Cake Tool

PsBash.Transpiler

The bash → PowerShell transpiler that powers PsBash: a hand-written lexer + recursive-descent parser (AST modeled on Oils/OSH) and a PowerShell emitter. It is a leaf library with no PsBash dependencies (only Parlot), so you can embed bash-to-PowerShell translation in your own app — for example to build your own shell on top of a PowerShell runspace.

dotnet add package PsBash.Transpiler

Transpile bash to PowerShell

using PsBash.Core.Transpiler; // assembly: PsBash.Transpiler

string ps = BashTranspiler.Transpile("ls -la | grep .log | sort -k5 -rn | head -5");
// ps == "Invoke-BashLs -la | Invoke-BashGrep .log | Invoke-BashSort -k5 -rn | Invoke-BashHead -5"

Transpile accepts an optional TranspileContext (Default, or Eval for eval-style in-process re-transpilation). Use TranspileWithMap when you need to map a PowerShell runtime error back to the originating bash line:

TranspileResult result = BashTranspiler.TranspileWithMap("for x in a b c; do echo $x; done");
string ps = result.PowerShell;       // emitted PowerShell
// result.LineMap: emitted line -> source bash line

Build your own shell

The emitted PowerShell calls Invoke-Bash* commands (e.g. Invoke-BashGrep). To run it with full fidelity, load the ps-bash runtime module into your runspace, then execute the transpiled text:

using System.Management.Automation;
using System.Management.Automation.Runspaces;

using var rs = RunspaceFactory.CreateRunspace();
rs.Open();
using var ps = PowerShell.Create();
ps.Runspace = rs;

// Load the runtime: the PsBash module (Invoke-Bash* commands) ships embedded in
// the PsBash.Core package and is extracted at runtime — add a reference to
// `PsBash.Core` and import the extracted module, or `Install-Module PsBash` /
// `PsBash.Cmdlets` from the PowerShell Gallery into the runspace.
ps.AddScript("Import-Module PsBash").Invoke();
ps.Commands.Clear();

string transpiled = BashTranspiler.Transpile(userBashLine);
foreach (var item in ps.AddScript(transpiled).Invoke())
    Console.WriteLine(item);

A REPL is then just: read a line → BashTranspiler.Transpile → run in the runspace → print. Add history, completion, and prompt handling to taste. See the ps-bash PsBash.Shell project for a complete launcher + host implementation.

Scope

  • In scope: bash syntax → PowerShell text. Lexer, parser, AST (PsBash.Core.Parser.Ast), emitter.
  • Out of scope (use PsBash.Core): the runtime Invoke-Bash* command implementations, the IPC host, and process orchestration.

License

MIT — see the repository.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PsBash.Transpiler:

Package Downloads
PsBash.Core

Bash-to-PowerShell transpiler library. Parses bash commands into an AST (based on Oils/OSH) and emits equivalent PowerShell. Use as a library in terminal emulators, AI agents, or any .NET app that needs bash compatibility on top of PowerShell.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.10.5 65 6/1/2026
0.10.4 72 5/29/2026
0.10.3 63 5/29/2026
0.10.2 66 5/29/2026
0.10.1 85 5/29/2026
0.10.0 77 5/29/2026
0.9.13 113 5/24/2026
0.9.11 117 5/22/2026
0.9.10 116 5/21/2026
0.9.9 112 5/21/2026
0.9.8 115 5/20/2026