Skip to content

Commit

Permalink
fix: fix poetry shell for nushell (#7919)
Browse files Browse the repository at this point in the history
  • Loading branch information
miikka authored May 15, 2023
1 parent 9d03170 commit 7f94625
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/poetry/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ def activate(self, env: VirtualEnv) -> int | None:

if self._name in ["zsh", "nu"]:
c.setecho(False)
if self._name == "zsh":
# Under ZSH the source command should be invoked in zsh's bash emulator
c.sendline(f"emulate bash -c '. {shlex.quote(str(activate_path))}'")

if self._name == "zsh":
# Under ZSH the source command should be invoked in zsh's bash emulator
c.sendline(f"emulate bash -c '. {shlex.quote(str(activate_path))}'")
else:
cmd = f"{self._get_source_command()} {shlex.quote(str(activate_path))}"
if self._name == "fish":
# Under fish "\r" should be sent explicitly
if self._name in ["fish", "nu"]:
# Under fish and nu "\r" should be sent explicitly
cmd += "\r"
c.sendline(cmd)

Expand Down Expand Up @@ -143,8 +144,10 @@ def _get_activate_script(self) -> str:
return "activate" + suffix

def _get_source_command(self) -> str:
if self._name in ("fish", "csh", "tcsh", "nu"):
if self._name in ("fish", "csh", "tcsh"):
return "source"
elif self._name == "nu":
return "overlay use"
return "."

def __repr__(self) -> str:
Expand Down

0 comments on commit 7f94625

Please sign in to comment.