Last active
April 10, 2019 08:43
-
-
Save tats-u/5de00598808843ad6ec0420055683bbc to your computer and use it in GitHub Desktop.
Enable `conda (de)activate` 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
function conda($cmd) { | |
# ↓ Change me | |
$scripts_root = "C:\tools\Anaconda3\Scripts" | |
function Add-ScriptsRootIfNeeded($exe) { | |
$ret = if (Get-Command $exe -ErrorAction Ignore) { | |
$exe | |
} | |
else { | |
Join-Path $scripts_root $exe | |
} | |
return $ret | |
} | |
switch -Exact ($cmd) { | |
"activate" { | |
& (Add-ScriptsRootIfNeeded "activate.ps1") @args | |
break | |
} | |
"deactivate" { | |
& (Add-ScriptsRootIfNeeded "deactivate.ps1") @args | |
break | |
} | |
default { | |
$all_args = if ($null -ne $cmd) { @($cmd) + $args } else { @() } | |
& (Add-ScriptsRootIfNeeded "conda.exe") @all_args | |
break | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment