PowerShell implementation of the pure prompt.
Loads git status information asynchronously so that the prompt doesn't block and is able to update the prompt in response to file system changes without any user interation.
- Terminal with ANSI colour support
- PowerShell 7.0
- Git 2.0 on your path
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 (e.g. for its excellent Git completion) then you'll probably want to import pure-pwsh first so that posh-git doesn't spend time configuring its own prompt.
# ~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1
Import-Module pure-pwsh
Import-Module posh-git
Set options on the $pure
global.
pure-pwsh should work anywhere PowerShell 7 does, including Windows, Mac, and Linux. Due to a longstanding bug in PSReadLine, async updates may not be scheduled on Mac and Linux until you interact with the console in some way.
- No vi mode indicator
- No git stash indicator
- No git action indicator (rebase, cherry pick, etc.)
- No python virtual env indicator
Consider raising an issue if you want any of the above, or use one of the recipes below.
Abbreviate each segment of the current path except for the leaf node.
$pure.PwdFormatter = {
(
((Split-Path $pwd).Replace($HOME, '~').Split($pwd.Provider.ItemSeparator) |% {$_[0]})
(Split-Path -Leaf $pwd)
) -join '/'
}
Truncate the branch name to a maximum of 12 characters.
$pure.BranchFormatter = {
param ($n)
$n.Length -lt 12 ? $n : ($n[0..11] -join '') '…'
}
$pure.PrePrompt = {
param ($user, $cwd, $git, $slow)
"`n$user{0}$cwd $git{1}$slow `n" -f($user ? ' ' : ''), ((git stash list) ? ' ≡ ' : '')
}
$pure.PrePrompt = {
param ($user, $cwd, $git, $slow)
"`n$user{1}{0}$cwd $git $slow `n" -f
($user ? ' ' : ''),
(($ve = $env:virtual_env) ? "$($pure._branchcolor)($(Split-Path -Leaf $ve)) " : "" )
}
$pure.UserColor = '38;5;242;4'
$pure.PrePrompt = {
param ($user, $cwd, $git, $slow)
$seperator = $pure._branchcolor " ❯ "
"`n$user{0}$cwd{1}$git$slow " -f
($user ? $seperator : ''),
($git ? $seperator : '')
}
$pure.UserFormatter = { param ($ssh, $user, $hostname) $ssh ? "$user`e[32m@$hostname" : '' }