Skip to content

Commit d641e67

Browse files
committed
simplify checks and update prompts
1 parent eff1156 commit d641e67

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

libmamba/src/core/activation.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1248,32 +1248,32 @@ namespace mamba
12481248

12491249
if (!env_transform.export_path.empty())
12501250
{
1251-
out << "PATH = " << env_transform.export_path << (util::on_win ? ';' : ':');
1251+
out << "PATH = " << env_transform.export_path << "\n";
12521252
}
12531253

12541254
for (const fs::u8path& ds : env_transform.deactivate_scripts)
12551255
{
1256-
out << "source " << ds << ";";
1256+
out << "source " << ds << "\n";
12571257
}
12581258

12591259
for (const std::string& uvar : env_transform.unset_vars)
12601260
{
1261-
out << "hide-env " << uvar << ";";
1261+
out << "hide-env " << uvar << "\n";
12621262
}
12631263

12641264
for (const auto& [skey, svar] : env_transform.set_vars)
12651265
{
1266-
out << "let " << skey << " = " << svar << ";";
1266+
out << "let " << skey << " = " << svar << "\n";
12671267
}
12681268

12691269
for (const auto& [ekey, evar] : env_transform.export_vars)
12701270
{
12711271
// add unix or windows handling
1272-
out << ekey << " = " << evar << (util::on_win ? ';' : ':');
1272+
out << ekey << " = " << evar << "\n";
12731273
}
12741274
for (const fs::u8path& p : env_transform.activate_scripts)
12751275
{
1276-
out << "source " << p << ";";
1276+
out << "source " << p << "\n";
12771277
}
12781278
return out.str();
12791279
}

libmamba/src/core/shell_init.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,21 @@ namespace mamba
496496
}
497497
#ask mamba how to setup the environment and set the environment
498498
(^($env.MAMBA_EXE) shell activate --shell nu $name
499+
| lines
499500
| str replace --regex '\s+' '' --all
500-
| split row (if $nu.os-info.name == "windows" { ";" } else { ":" })
501-
| parse --regex '(.*)=(.+)'
502-
| transpose --header-row
503-
| into record
501+
| parse --regex '([^=]+)=(.+)'
502+
| reduce -f {} { |it, acc|
503+
$acc | merge {
504+
$it.capture0: (
505+
if ($it.capture0 == "PATH") or ($it.capture0 | str ends-with "_PATH") {
506+
$it.capture1 | split row (if $nu.os-info.name == "Windows" { ";" } else { ":" }) | where { |path| $path != "" }
507+
} else {
508+
$it.capture1
509+
}
510+
)
511+
}
512+
}
504513
| load-env
505-
)
506-
$env.PATH = $env.PATH | split row (char esep)
507514
# update prompt
508515
if ($env.CONDA_PROMPT_MODIFIER? != null) {
509516
$env.PROMPT_COMMAND = {|| $env.CONDA_PROMPT_MODIFIER + (do $env.PROMPT_COMMAND_BK)}

0 commit comments

Comments
 (0)