mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00

This PR is part of porting all old scripts #221 and includes the `virtual_environments` module ## 5 files changed - `conda.nu`: removed, already in `modules/virtual_enviromnents/conda/nu_conda.nu` - `conda_deactivate.nu`: also removed, has already been merged with `nu_conda.nu` - `README.nu`: removed, similar info in `modules/virtual_enviromnents/README.md` - `venv.nu`: ported to `modules/virtual_enviromnents/venv/venv.nu` - `venv_deactivate.nu`: ported to `modules/virtual_enviromnents/venv/venv_deactivate.nu`
25 lines
645 B
Text
25 lines
645 B
Text
export def --env activate [venv_dir] {
|
|
let venv_abs_dir = ($venv_dir | path expand)
|
|
let venv_name = ($venv_abs_dir | path basename)
|
|
let old_path = $env.PATH
|
|
let new_path = (venv-path $venv_abs_dir)
|
|
let new_env = ({VENV_OLD_PATH: $old_path, VIRTUAL_ENV: $venv_name} | merge $new_path)
|
|
load-env $new_env
|
|
}
|
|
|
|
def "venv-path" [venv_dir] {
|
|
let env_path = [
|
|
$venv_dir,
|
|
([$venv_dir, "bin"] | path join)
|
|
]
|
|
return {
|
|
PATH: ($env.PATH | prepend $env_path)
|
|
}
|
|
}
|
|
|
|
export def --env deactivate [] {
|
|
$env.PATH = $env.VENV_OLD_PATH
|
|
hide-env VIRTUAL_ENV
|
|
hide-env VENV_OLD_PATH
|
|
|
|
}
|