1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-02 07:07:46 +00:00

Updated conda script to default to base if no arg given (#409)

This commit is contained in:
Tilen Gimpelj 2023-03-13 15:21:21 +01:00 committed by GitHub
parent 34235efe5f
commit e95f60971b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,14 +1,19 @@
# Activate conda environment
export def-env activate [
env_name: string@'nu-complete conda envs' # name of the environment
--no-prompt # do not update the prompt
env_name?: string@'nu-complete conda envs' # name of the environment
--no-prompt # do not update the prompt
] {
let conda_info = (conda info --envs --json | from json)
mut env_dir = ($conda_info.envs_dirs | each {|it| $it | path join $env_name })
mut $env_name = $env_name
if $env_name == null {$env_name = "base"}
mut env_dir = ""
mut env_dirs = []
for i in $conda_info.envs_dirs {
$env_dirs = ($env_dirs | append ($i | path join $env_name))
}
if $env_name != "base" {
$env_dir = (check-if-env-exists $env_name $env_dir)
$env_dir = ((check-if-env-exists $env_name $env_dirs) | into string)
} else {
$env_dir = $conda_info.root_prefix
}