Last active
November 22, 2018 13:51
-
-
Save emredjan/9044bb28f870f5f8b158d766da0db544 to your computer and use it in GitHub Desktop.
Activate conda environment in PowerShell
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
Param | |
( | |
[parameter(Position=0, Mandatory=$true)] | |
[String] | |
$env_name | |
) | |
# simulate activation of Conda environment | |
$cenv = "C:\Path\to\anaconda\installation\envs\$env_name" | |
$Env:CONDA_PREFIX = $cenv | |
$Env:CONDA_DEFAULT_ENV = $env_name | |
$Env:PATH = "$cenv;$cenv\Library\mingw-w64\bin;$cenv\Library\usr\bin;$cenv\Library\bin;$cenv\Scripts;$cenv\bin;$Env:PATH" | |
# add env name to prompt | |
function global:UserPrompt {''} | |
$Function:UserPrompt = $Function:prompt | |
function global:prompt | |
{ | |
"($Env:CONDA_DEFAULT_ENV) " + (UserPrompt) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment