Skip to content

Commit

Permalink
fix: prefix conda commands with conda (#816)
Browse files Browse the repository at this point in the history
I wasn't sure if this was on purpose or not but the conda environments
were simply "activate" and "deactivate" instead of "conda activate" and
"conda deactivate" as they would be normally in bash/zsh.

Due to the potential name conflicts I think it's better to leave these
as the more specific `conda activate` and let the user define an alias
in their file with `alias activate = conda activate`
  • Loading branch information
MilesCranmer committed Apr 12, 2024
1 parent 2d3406b commit 0d665a7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions modules/virtual_environments/conda.nu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Activate conda environment
export def --env activate [
export def --env "conda activate" [
env_name?: string@'nu-complete conda envs' # name of the environment
] {
let conda_info = (conda info --envs --json | from json)
Expand Down Expand Up @@ -73,7 +73,7 @@ export def --env activate [
}

# Deactivate currently active conda environment
export def --env deactivate [] {
export def --env "conda deactivate" [] {
let path_name = if "PATH" in $env { "PATH" } else { "Path" }
$env.$path_name = $env.CONDA_OLD_PATH

Expand Down
6 changes: 3 additions & 3 deletions modules/virtual_environments/nu_conda/nu_conda.nu
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export-env {
$env.CONDA_CURR = null
}

export def --env activate [name: string] {
export def --env "conda activate" [name: string] {
if ($env.CONDA_ROOT | is-empty) {
print "Neither Conda nor Mamba is valid."
return
Expand All @@ -44,7 +44,7 @@ export def --env activate [name: string] {
load-env ({CONDA_CURR: $name} | merge $new_path)
}

export def --env deactivate [] {
export def --env "conda deactivate" [] {
if ($env.CONDA_ROOT | is-empty) {
print "Neither Conda nor Mamba is valid."
return
Expand All @@ -55,7 +55,7 @@ export def --env deactivate [] {
load-env {Path: $env.CONDA_BASE_PATH, PATH: $env.CONDA_BASE_PATH}
}

export def --env list [] {
export def --env "conda list" [] {
$env.CONDA_ENVS |
flatten |
transpose |
Expand Down
4 changes: 2 additions & 2 deletions modules/virtual_environments/nu_conda_2/conda.nu
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def --env load-conda-info-env [] {
}

# Activate conda environment
export def --env activate [
export def --env "conda activate" [
env_name: string@'nu-complete conda envs' = "base" # name of the environment
] {
load-conda-info-env
Expand Down Expand Up @@ -94,7 +94,7 @@ export def --env activate [
}

# Deactivate currently active conda environment
export def --env deactivate [] {
export def --env "conda deactivate" [] {
let path_name = if "PATH" in $env { "PATH" } else { "Path" }
$env.$path_name = $env.CONDA_OLD_PATH

Expand Down

0 comments on commit 0d665a7

Please sign in to comment.