0

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

PS>

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>
3
  • What's your PowerShell Profile got in it? Jun 24, 2019 at 3:30
  • Sorry? I don't know what are you talking about. @music2myear
    – Neo
    Jun 24, 2019 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/… Jun 24, 2019 at 15:22

1 Answer 1

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .