Last active
November 12, 2024 12:53
-
-
Save guimondmm/1a2e47d73a191429c7f8b0c12729dc59 to your computer and use it in GitHub Desktop.
Add an "Anaconda PowerShell Prompt" profile to Windows Terminal. Just paste it in your settings.json file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"colorScheme": "Campbell", | |
"commandline": "pwsh.exe -ExecutionPolicy ByPass -NoExit -Command \"& '%USERPROFILE%\\anaconda3\\shell\\condabin\\conda-hook.ps1' ; conda activate '%USERPROFILE%\\anaconda3' \"", | |
"guid": "{e7d34d61-5a57-4f38-8eab-91cb777b0c26}", | |
"hidden": false, | |
"icon": "%USERPROFILE%\\anaconda3\\Menu\\anaconda-navigator.ico", | |
"name": "Anaconda PowerShell Prompt", | |
"startingDirectory": "%USERPROFILE%" | |
} |
works like a charm. thanks.
i had to change pwsh.exe
to powershell.exe
, works great other than that
Folks should change the GUID.
Below is the section if using miniconda
{ "commandline": "%PROGRAMFILES%\\PowerShell\\7\\pwsh.exe -ExecutionPolicy ByPass -NoExit -Command \"& '%USERPROFILE%\\miniconda3\\shell\\condabin\\conda-hook.ps1' ; conda activate '%USERPROFILE%\\miniconda3' \"", "guid": "{ba3f6141-a2f2-5472-b294-a7d7fb0e264f}", "icon": "%USERPROFILE%\\miniconda3\\Menu\\anaconda_powershell_prompt.ico", "name": "miniconda3 powershell 7", "startingDirectory": "%USERPROFILE%" }
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
This Windows Terminal profile launches PowerShell with exactly the same command as Anaconda Navigator does, except it uses the new and improved
pwsh.exe
(PowerShell Core), instead of the oldpowershell.exe
(Windows PowerShell 5.1), which still ships with Windows as of writing these lines.That is to say, this profile sources Anaconda's
conda-hook.ps1
script, which automatically sets the required environment variables, and activates the base Conda environment. This means you don't need to add Conda to PATH to use your Conda environment in Windows Terminal. It's also more convenient and much faster to launch PowerShell this way than to letconda init
wreak havoc on your PowerShell profile.Just paste this profile at the appropriate location inside your
settings.json
file, which can be accessed by click the cog in the lower left corner of the Windows Terminal Settings pane.Caveats
pwsh.exe
in PATH. If you'd prefer to hardcode the path instead, you can use the(Get-Command 'pwsh.exe').Path
cmdlet to get the full path topwsh.exe
.%USERPROFILE%\anaconda3
, which is the default folder. Change the path if need be.conda init
make changes to yourMicrosoft.Powershell_profile.ps1
file.settings.json
file. Also, don't forget to escape double quotes and backslashes if you edit the paths to PowerShell or Anaconda.New-Guid
cmdlet.