So I have this PowerShell configuration file, git branches are showing just fine, the problem is when I'm in every folder location is shows PS
at the end:
Here's my script (I don't really know if I'm missing something here, maybe with the else
path):
function prompt { $p = Split-Path -leaf -path (Get-Location) $user = $env:UserName $host.UI.RawUI.WindowTitle = "\" + $p + ">" $host.UI.RawUI.ForegroundColor = "Blue" if (Test-Path .git) { $p = Split-Path -leaf -path (Get-Location) git branch | ForEach-Object { if ($_ -match "^\*(.*)") { $branch = $matches[1] + " - " Write-Host -NoNewLine $user -ForegroundColor Magenta Write-Host -NoNewLine "@\" Write-Host -NoNewLine $p -ForegroundColor Yellow Write-Host -NoNewLine " - " -ForegroundColor DarkGreen Write-Host -NoNewLine $branch -ForegroundColor DarkGreen } } } else { Write-Host -NoNewLine $user -ForegroundColor Magenta Write-Host -NoNewLine "@\" Write-Host -NoNewLine $p -ForegroundColor Yellow Write-Host -NoNewLine " " } }
https://stackoverflow.com/questions/66809646/powershell-configuration-file March 26, 2021 at 09:04AM
没有评论:
发表评论