My custom PowerShell prompt without the use of oh-my-posh. Create or open file with name Microsoft.PowerShell_profile.ps1 at location C:\Users\<your user name>\Documents\PowerShell\ and paste this code inside that. Then open a PowerShell window to check the prompt.
function prompt
{
[string] $currentFolderName = GetCurrentFolderName
[string] $gitStatus = (git status)
if ([string]::IsNullOrEmpty($gitStatus))
{
Write-Host "→ $currentFolderName" -NoNewLine -ForegroundColor DarkCyan
}
else
{
Write-Host "→ $currentFolderName (" -NoNewLine -ForegroundColor DarkCyan
Write-Host "$(git branch --show-current)" -NoNewLine -ForegroundColor DarkRed
Write-Host ")" -NoNewLine -ForegroundColor DarkCyan
}
return " "
}
function GetCurrentFolderName
{
[string] $location = Get-Location
[string] $currentFolderName = [string]::Empty
if ($location.EndsWith("\"))
{
$currentFolderName = $location
}
else
{
[int] $lastIndexOfSlash = $location.LastIndexOf("\")
$currentFolderName = $location.SubString($lastIndexOfSlash + 1)
}
return $currentFolderName
}
