When I add the code below to C:\Users\USERFOLDER\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:
function prompt
{
$ESC = [char]27
"$ESC[46mPS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) $ESC[0m"
}
(as suggested in How to colorize the Powershell prompt?)
My prompt then omits conda's environment prefix (e.g. base), despite the environment being activated.
How can I have a colored prompt but still keep conda's prefix?
Other related questions that do not answer mine:
Answers here that did not solve the problem either:
function prompt {
$envName = (Get-Command conda | Select-String "activate" -Context 0,1).Context.PostContext -replace '>',''
$promptColor = "Yellow" # Change color as desired
Write-Host "[$envName] " -NoNewline -ForegroundColor $promptColor
return "PS
$($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
}
And the following seemed to be the other suggestion, but it wasn't clear to me from the code posted:
function prompt {
write-host "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) " -foregroundcolor red -nonewline
}
I also tried
function prompt{
write-host "PS " -ForegroundColor Magenta -NoNewline
return "$((Get-Location).path)> "
}

