mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
Add Windows support
The path env var on Windows is Path, not PATH. This commit includes that difference when differentiating between OS.
This commit is contained in:
parent
2b3312fc06
commit
9c7822aa18
2 changed files with 13 additions and 8 deletions
|
@ -3,31 +3,35 @@ def conda-env [env-name] {
|
|||
let suffix = (if $env-name == "base" {""} {(["envs" $env-name] | path join)})
|
||||
let env-dir = ([$conda-info.root_prefix $suffix] | path join)
|
||||
let old-path = ($nu.path | str collect (path-sep))
|
||||
let env-path = (if (windows?) { (conda-create-path-windows $env-dir) } { (conda-create-path-unix $env-dir) })
|
||||
let new-path = ([$env-path $nu.path] | flatten | str collect (path-sep))
|
||||
[[name, value];
|
||||
let new-path = (if (windows?) { (conda-create-path-windows $env-dir) } { (conda-create-path-unix $env-dir) })
|
||||
let new-env = [[name, value];
|
||||
[CONDA_DEFAULT_ENV $env-name]
|
||||
[CONDA_PREFIX $env-dir]
|
||||
[CONDA_PROMPT_MODIFIER $"[($env-name)]"]
|
||||
[CONDA_SHLVL "1"]
|
||||
[CONDA_OLD_PATH $old-path]
|
||||
[PATH $new-path]]
|
||||
[CONDA_OLD_PATH $old-path]]
|
||||
|
||||
$new-env | append $new-path
|
||||
}
|
||||
|
||||
def conda-create-path-windows [env-dir] {
|
||||
[
|
||||
let env-path = [
|
||||
$env-dir
|
||||
([$env-dir "Scripts"] | path join)
|
||||
([$env-dir "Library" "mingw-w64"] | path join)
|
||||
([$env-dir "Library" "bin"] | path join)
|
||||
([$env-dir "Library" "usr" "bin"] | path join)
|
||||
]
|
||||
let new-path = ([$env-path $nu.path] | flatten | str collect (path-sep))
|
||||
[[name, value]; [Path $new-path]]
|
||||
}
|
||||
|
||||
def conda-create-path-unix [env-dir] {
|
||||
[
|
||||
let env-path = [
|
||||
([$env-dir "bin"] | path join)
|
||||
]
|
||||
let new-path = ([$env-path $nu.path] | flatten | str collect (path-sep))
|
||||
[[name, value]; [PATH $new-path]]
|
||||
}
|
||||
|
||||
def windows? [] {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
let-env PATH = $nu.env.CONDA_OLD_PATH
|
||||
let path-name = (if ((sys).host.name == "Windows") { "Path" } { "PATH" })
|
||||
let-env $path-name = $nu.env.CONDA_OLD_PATH
|
||||
unlet-env CONDA_PROMPT_MODIFIER
|
||||
unlet-env CONDA_PREFIX
|
||||
unlet-env CONDA_SHLVL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue