Created
January 9, 2025 08:00
-
-
Save ochen1/35e9b521c59cdb5b4a2f2f8f5045a94a to your computer and use it in GitHub Desktop.
Lazy load conda in PowerShell (drop-in replacement)
This file contains hidden or 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
# ~/Documents/WindowsPowerShell/profile.ps1 | |
function Conda { | |
# Check if the initialization has already been performed | |
if (-not $global:CondaInitialized) { | |
# Perform the initialization | |
if (Test-Path "C:\ProgramData\miniconda3\Scripts\conda.exe") { | |
(& "C:\ProgramData\miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | ?{$_} | Invoke-Expression | |
} else { | |
Write-Error "Conda executable not found at the specified path." | |
return | |
} | |
# Set the flag to indicate initialization is complete | |
$global:CondaInitialized = $true | |
} | |
# Pass the original arguments to the conda command | |
& conda @args | |
} | |
# Ensure the function is loaded in the current session | |
#Set-Alias conda Conda |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment