GitPrompt.psm1
|
function Get-GitSimplePrompt { [CmdletBinding()] param( [Parameter(Position = 0)] [string]$Path, # Fast mode: skip the worktree scan for untracked files (passes -uno). # Untracked files are counted by default. [switch]$NoUntracked, # Fast mode: skip ahead/behind computation against the upstream. [switch]$NoAheadBehind, # Show "repo/relative-path" before the branch when inside a subdirectory. [switch]$Subdir, # Return the structured GitStatus record instead of the formatted string. [switch]$Raw, # Emit ANSI colors (branch cyan, untracked yellow, conflicts red, stash magenta). [switch]$Color ) $targetPath = if ($PSBoundParameters.ContainsKey('Path')) { if ([string]::IsNullOrWhiteSpace($Path)) { '' } else { try { (Resolve-Path -LiteralPath $Path).ProviderPath } catch { $Path } } } else { (Get-Location).ProviderPath } if ($Raw) { return [GitPredictor.SimpleGitPrompt]::TryGetStatus( $targetPath, -not [bool]$NoUntracked, -not [bool]$NoAheadBehind, [bool]$Subdir) } $result = [GitPredictor.SimpleGitPrompt]::TryBuildPrompt( $targetPath, -not [bool]$NoUntracked, -not [bool]$NoAheadBehind, [bool]$Subdir, [bool]$Color) if ($null -ne $result) { $result } } Export-ModuleMember -Function Get-GitSimplePrompt |