Skip to content

Commit

Permalink
Use only single quotes
Browse files Browse the repository at this point in the history
Double quotes gave errors with Windows paths.
  • Loading branch information
kubouch committed Mar 22, 2022
1 parent b3232d7 commit 7d77429
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
44 changes: 22 additions & 22 deletions src/virtualenv/activation/nushell/activate.nu
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# This command prepares the required environment variables
def-env activate-virtualenv [] {
def is-string [x] {
($x | describe) == "string"
($x | describe) == 'string'
}

def has-env [name: string] {
$name in (env).name
}

let is-windows = ((sys).host.name | str downcase) == "windows"
let virtual-env = "__VIRTUAL_ENV__"
let bin = "__BIN_NAME__"
let path-sep = "__PATH_SEP__"
let is-windows = ((sys).host.name | str downcase) == 'windows'
let virtual-env = '__VIRTUAL_ENV__'
let bin = '__BIN_NAME__'
let path-sep = '__PATH_SEP__'
let path-name = if $is-windows {
if (has-env "Path") {
"Path"
if (has-env 'Path') {
'Path'
} else {
"PATH"
'PATH'
}
} else {
"PATH"
'PATH'
}

let old-path = (
if $is-windows {
if (has-env "Path") {
if (has-env 'Path') {
$env.Path
} else {
$env.PATH
Expand All @@ -43,32 +43,32 @@ def-env activate-virtualenv [] {
let new-path = ($old-path | prepend $venv-path | str collect $path-sep)

# Creating the new prompt for the session
let virtual-prompt = if ("__VIRTUAL_PROMPT__" == "") {
$"(char lparen)($virtual-env | path basename)(char rparen) "
let virtual-prompt = if ('__VIRTUAL_PROMPT__' == '') {
$'(char lparen)($virtual-env | path basename)(char rparen) '
} else {
"(__VIRTUAL_PROMPT__) "
'(__VIRTUAL_PROMPT__) '
}

# Back up the old prompt builder
let old-prompt-command = if (has-env "VIRTUAL_ENV") && (has-env "_OLD_PROMPT_COMMAND") {
let old-prompt-command = if (has-env 'VIRTUAL_ENV') && (has-env '_OLD_PROMPT_COMMAND') {
$env._OLD_PROMPT_COMMAND
} else {
if (has-env "PROMPT_COMMAND") {
if (has-env 'PROMPT_COMMAND') {
$env.PROMPT_COMMAND
} else {
""
''
}
}

# If there is no default prompt, then only the env is printed in the prompt
let new-prompt = if (has-env "PROMPT_COMMAND") {
if ($old-prompt-command | describe) == "block" {
{ $"($virtual-prompt)(do $old-prompt-command)" }
let new-prompt = if (has-env 'PROMPT_COMMAND') {
if ($old-prompt-command | describe) == 'block' {
{ $'($virtual-prompt)(do $old-prompt-command)' }
} else {
{ $"($virtual-prompt)($old-prompt-command)" }
{ $'($virtual-prompt)($old-prompt-command)' }
}
} else {
{ $"($virtual-prompt)" }
{ $'($virtual-prompt)' }
}

# Environment variables that will be batched loaded to the virtual env
Expand All @@ -89,4 +89,4 @@ def-env activate-virtualenv [] {
activate-virtualenv

alias pydoc = python -m pydoc
alias deactivate = source "__DEACTIVATE_PATH__"
alias deactivate = source '__DEACTIVATE_PATH__'
10 changes: 5 additions & 5 deletions src/virtualenv/activation/nushell/deactivate.nu
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ def-env deactivate-virtualenv [] {
$name in (env).name
}

let is-windows = ((sys).host.name | str downcase) == "windows"
let is-windows = ((sys).host.name | str downcase) == 'windows'

let path-name = if $is-windows {
if (has-env "Path") {
"Path"
if (has-env 'Path') {
'Path'
} else {
"PATH"
'PATH'
}
} else {
"PATH"
'PATH'
}

load-env { $path-name : $env._OLD_VIRTUAL_PATH }
Expand Down

0 comments on commit 7d77429

Please sign in to comment.