summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Herrera <fernando.j.herrera@gmail.com>2021-09-18 18:21:18 +0100
committerGitHub <noreply@github.com>2021-09-18 18:21:18 +0100
commit2151d385094c4f320cd2484eb9bcf3272cea2cc3 (patch)
treebbe4ce33db945893b30721b802b66e40ef9e9f8f
parentd810ce1c0613d1b955576bca644335b7a00b5bc0 (diff)
downloadvirtualenv-2151d385094c4f320cd2484eb9bcf3272cea2cc3.tar.gz
Improve prompt nushell (#2190)
-rw-r--r--src/virtualenv/activation/nushell/activate.nu9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/virtualenv/activation/nushell/activate.nu b/src/virtualenv/activation/nushell/activate.nu
index f0a4da4..c1b6c32 100644
--- a/src/virtualenv/activation/nushell/activate.nu
+++ b/src/virtualenv/activation/nushell/activate.nu
@@ -1,4 +1,5 @@
# Setting all environment variables for the venv
+let path-name = (if ((sys).host.name == "Windows") { "Path" } { "PATH" })
let virtual-env = "__VIRTUAL_ENV__"
let bin = "__BIN_NAME__"
let path-sep = "__PATH_SEP__"
@@ -11,7 +12,7 @@ let new-path = ($nu.path | prepend $venv-path | str collect ($path-sep))
# environment variables that will be batched loaded to the virtual env
let new-env = ([
[name, value];
- [PATH $new-path]
+ [$path-name $new-path]
[_OLD_VIRTUAL_PATH $old-path]
[VIRTUAL_ENV $virtual-env]
])
@@ -22,15 +23,15 @@ load-env $new-env
let virtual_prompt = (if ("__VIRTUAL_PROMPT__" != "") {
"__VIRTUAL_PROMPT__"
} {
- $virtual-env | path basename
+ (build-string '(' ($virtual-env | path basename) ') ')
}
)
# If there is no default prompt, then only the env is printed in the prompt
let new_prompt = (if ( config | select prompt | empty? ) {
- ($"build-string '(char lparen)' '($virtual_prompt)' '(char rparen) ' ")
+ ($"build-string '($virtual_prompt)'")
} {
- ($"build-string '(char lparen)' '($virtual_prompt)' '(char rparen) ' (config get prompt | str find-replace "build-string" "")")
+ ($"build-string '($virtual_prompt)' (config get prompt | str find-replace "build-string" "")")
})
let-env PROMPT_COMMAND = $new_prompt