After executing conda init, now every time I open PS, it displays:


rather than with the current directory

PS C:\Users\Me>

How do I make PS show me the current path?

I have a solution to add a PS script like:

function prompt {
  $p = Get-Location
  "$p> "

But the problem is that, though I have my current directory now, I won't be able to see my current env in conda. This means after excuting conda activate myenv, current env myenv is not displayed, while on the other hand I expect to see:

(myenv) PS C:\somePath>
  • What's your PowerShell Profile got in it? – music2myear Jun 24 '19 at 3:30
  • Sorry? I don't know what are you talking about. @music2myear – Neo Jun 24 '19 at 4:11
  • Powershell has profiles you can use to set all sorts of options in. My first guess would be that Conda added something to your Powershell profile that makes this change. There are several files that build your PS profile. It would be helpful to read this to begin learning about these: docs.microsoft.com/en-us/powershell/module/… – music2myear Jun 24 '19 at 15:22

Short version is to try this in a Powershell session: Add-CondaEnvironmentToPrompt

To alter the Powershell prompt, the above answer is correct but these sites have more concise explanations for doint it: $Profile-Powershell Powershell Prompt Function

The $profile automatic variable will show the location of your Profile.ps1 file: PS > "$Profile"

You should find a conda region like:

region conda initialize ...\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Invoke-Expression ... endregion

If you change 'Out-String' to 'Out-Host' then the commands should be displayed when Powershell is launched. 'Add-CondaEnvironmentToPrompt' should be in there somewhere. Copy and paste that below the conda region in your "$Profile". Change the file back to 'Out-String' and relaunch Powershell.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.