Skip to content

Commit 2151d38

Browse files
authored
Improve prompt nushell (#2190)
1 parent d810ce1 commit 2151d38

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/virtualenv/activation/nushell/activate.nu

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Setting all environment variables for the venv
2+
let path-name = (if ((sys).host.name == "Windows") { "Path" } { "PATH" })
23
let virtual-env = "__VIRTUAL_ENV__"
34
let bin = "__BIN_NAME__"
45
let path-sep = "__PATH_SEP__"
@@ -11,7 +12,7 @@ let new-path = ($nu.path | prepend $venv-path | str collect ($path-sep))
1112
# environment variables that will be batched loaded to the virtual env
1213
let new-env = ([
1314
[name, value];
14-
[PATH $new-path]
15+
[$path-name $new-path]
1516
[_OLD_VIRTUAL_PATH $old-path]
1617
[VIRTUAL_ENV $virtual-env]
1718
])
@@ -22,15 +23,15 @@ load-env $new-env
2223
let virtual_prompt = (if ("__VIRTUAL_PROMPT__" != "") {
2324
"__VIRTUAL_PROMPT__"
2425
} {
25-
$virtual-env | path basename
26+
(build-string '(' ($virtual-env | path basename) ') ')
2627
}
2728
)
2829

2930
# If there is no default prompt, then only the env is printed in the prompt
3031
let new_prompt = (if ( config | select prompt | empty? ) {
31-
($"build-string '(char lparen)' '($virtual_prompt)' '(char rparen) ' ")
32+
($"build-string '($virtual_prompt)'")
3233
} {
33-
($"build-string '(char lparen)' '($virtual_prompt)' '(char rparen) ' (config get prompt | str find-replace "build-string" "")")
34+
($"build-string '($virtual_prompt)' (config get prompt | str find-replace "build-string" "")")
3435
})
3536
let-env PROMPT_COMMAND = $new_prompt
3637

0 commit comments

Comments
 (0)