Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poetry shell: fix nushell #8478

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/poetry/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,30 @@ def activate(self, env: VirtualEnv) -> int | None:
import shlex

terminal = shutil.get_terminal_size()
cmd = f"{self._get_source_command()} {shlex.quote(str(activate_path))}"

with env.temp_environ():
args = ["-e", cmd] if self._name == "nu" else ["-i"]

c = pexpect.spawn(
self._path, ["-i"], dimensions=(terminal.lines, terminal.columns)
self._path, args, dimensions=(terminal.lines, terminal.columns)
)

if self._name in ["zsh", "nu"]:
if self._name in ["zsh"]:
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))}'")
elif self._name == "xonsh":
c.sendline(f"vox activate {shlex.quote(str(env.path))}")
elif self._name == "nu":
# If this is nu, we don't want to send the activation command to the
# command line since we already ran it via the shell's invocation.
pass
radoering marked this conversation as resolved.
Show resolved Hide resolved
else:
cmd = f"{self._get_source_command()} {shlex.quote(str(activate_path))}"
if self._name in ["fish", "nu"]:
# Under fish and nu "\r" should be sent explicitly
if self._name in ["fish"]:
# Under fish, "\r" should be sent explicitly
cmd += "\r"
c.sendline(cmd)

Expand Down