PowerShell implementation of the pure prompt.
- Terminal with ANSI colour support (e.g. any modern version of Windows 10, ConEmu, Hyper, ansicon, etc.)
- PSReadLine for async prompt updates. Works best with PSReadLine 2.0.
Set options on the $pure
global.
To customise the formatting of the current git branch or working directory, provide a function that transforms a string parameter into a string output. For example, this truncates the branch name by underscore delimited segments:
$pure.BranchFormatter = {
$args |% {
@(((($_ -split '_' | select -First 3) -join '_') + '…'), $_)
} | sort Length | select -First 1
}
Similarly, you can customise the entire upper line by providing a function that transforms three string parameters
($cwd
, $git
and $slow
) into a string output. For example, to include your username before the directory info:
$pure.PrePrompt = {param ($cwd, $git, $slow) "`n$($pure._branchColor)$([Environment]::UserName) $cwd $git $slow`n"}
Or to put the entire prompt on one line, remove the `n
at the end of the pre-prompt:
$pure.PrePrompt = {param ($cwd, $git, $slow) "`n$cwd $git $slow"}
Further customisations can be easily made, for example to color your username a unique color you can provide an ANSI escade code, as follows
myColours = @{ blue = "`e[38;5;31m" }
$pure.PrePrompt =
{param ($cwd, $git, $slow) "`n$($myColours.blue)$([Environment]::UserName) $cwd $git $slow"}
which colors the username deep sky blue 3.
Install from the gallery or clone this repository:
Install-Module pure-pwsh
and import it in your profile. If you use this with posh-git
(recommended for its excellent command completion)
then you'll probably want to import pure-pwsh
first so that posh-git
doesn't waste time configuring the prompt.
Import-Module pure-pwsh
The packaged dependencies are built for the Windows x64 platform. To build for an alternative platform,
cd
into the directory containing PurePwsh.csproj
(i.e. $env:PSModulePath/pure-pwsh/[version]/pure-pwsh
)
and run:
dotnet publish -o bin -c Release -r [your-runtime] # https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
- Does not display username and host for remote sessions
- Does not set window title
- No vi mode indicator
Consider raising an issue if you want any of the above.