prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Update prompt environment variable when opening shell
  <!--
    Hi there! Thank you for wanting to make Poetry better.
  
    Before you submit this; let's make sure of a few things.
    Please make sure the following boxes are ticked if they are correct.
    If not, please try and fulfill these first.
  -->
  
  <!-- Checked checkbox should look like this: [x] -->
  - [x] I have searched the [issues](https://github.com/sdispater/poetry/issues) of this repo and believe that this is not a duplicate.
  - [x] I have searched the [documentation](https://poetry.eustace.io/docs/) and believe that my question is not covered.
  
  ## Feature Request
  <!-- Now feel free to write your idea for improvement. Thanks again 🙌 ❤️ -->
  When running `poetry shell` you have no idea your in the virtualenv or not. Please add the virtualenv's name to the $PROMPT or $PS1 variable.
  
  </issue>
  <code>
  [start of src/poetry/utils/shell.py]
  1 import os
  2 import signal
  3 import sys
  4 
  5 from pathlib import Path
  6 from typing import TYPE_CHECKING
  7 from typing import Any
  8 from typing import Optional
  9 
  10 import pexpect
  11 
  12 from cleo.terminal import Terminal
  13 from shellingham import ShellDetectionFailure
  14 from shellingham import detect_shell
  15 
  16 from poetry.utils._compat import WINDOWS
  17 
  18 
  19 if TYPE_CHECKING:
  20     from poetry.utils.env import VirtualEnv
  21 
  22 
  23 class Shell:
  24     """
  25     Represents the current shell.
  26     """
  27 
  28     _shell = None
  29 
  30     def __init__(self, name: str, path: str) -> None:
  31         self._name = name
  32         self._path = path
  33 
  34     @property
  35     def name(self) -> str:
  36         return self._name
  37 
  38     @property
  39     def path(self) -> str:
  40         return self._path
  41 
  42     @classmethod
  43     def get(cls) -> "Shell":
  44         """
  45         Retrieve the current shell.
  46         """
  47         if cls._shell is not None:
  48             return cls._shell
  49 
  50         try:
  51             name, path = detect_shell(os.getpid())
  52         except (RuntimeError, ShellDetectionFailure):
  53             shell = None
  54 
  55             if os.name == "posix":
  56                 shell = os.environ.get("SHELL")
  57             elif os.name == "nt":
  58                 shell = os.environ.get("COMSPEC")
  59 
  60             if not shell:
  61                 raise RuntimeError("Unable to detect the current shell.")
  62 
  63             name, path = Path(shell).stem, shell
  64 
  65         cls._shell = cls(name, path)
  66 
  67         return cls._shell
  68 
  69     def activate(self, env: "VirtualEnv") -> Optional[int]:
  70         if WINDOWS:
  71             return env.execute(self.path)
  72 
  73         import shlex
  74 
  75         terminal = Terminal()
  76         with env.temp_environ():
  77             c = pexpect.spawn(
  78                 self._path, ["-i"], dimensions=(terminal.height, terminal.width)
  79             )
  80 
  81         if self._name == "zsh":
  82             c.setecho(False)
  83 
  84         activate_script = self._get_activate_script()
  85         bin_dir = "Scripts" if WINDOWS else "bin"
  86         activate_path = env.path / bin_dir / activate_script
  87         c.sendline(f"{self._get_source_command()} {shlex.quote(str(activate_path))}")
  88 
  89         def resize(sig: Any, data: Any) -> None:
  90             terminal = Terminal()
  91             c.setwinsize(terminal.height, terminal.width)
  92 
  93         signal.signal(signal.SIGWINCH, resize)
  94 
  95         # Interact with the new shell.
  96         c.interact(escape_character=None)
  97         c.close()
  98 
  99         sys.exit(c.exitstatus)
  100 
  101     def _get_activate_script(self) -> str:
  102         if self._name == "fish":
  103             suffix = ".fish"
  104         elif self._name in ("csh", "tcsh"):
  105             suffix = ".csh"
  106         else:
  107             suffix = ""
  108 
  109         return "activate" + suffix
  110 
  111     def _get_source_command(self) -> str:
  112         if self._name in ("fish", "csh", "tcsh"):
  113             return "source"
  114         return "."
  115 
  116     def __repr__(self) -> str:
  117         return f'{self.__class__.__name__}("{self._name}", "{self._path}")'
  118
  [end of src/poetry/utils/shell.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py
  --- a/src/poetry/utils/shell.py
  +++ b/src/poetry/utils/shell.py
  @@ -1,5 +1,6 @@
   import os
   import signal
  +import subprocess
   import sys
   
   from pathlib import Path
  @@ -67,8 +68,19 @@
           return cls._shell
   
       def activate(self, env: "VirtualEnv") -> Optional[int]:
  +        activate_script = self._get_activate_script()
  +        bin_dir = "Scripts" if WINDOWS else "bin"
  +        activate_path = env.path / bin_dir / activate_script
  +
           if WINDOWS:
  -            return env.execute(self.path)
  +            if self._name in ("powershell", "pwsh"):
  +                args = ["-NoExit", "-File", str(activate_path)]
  +            else:
  +                # /K will execute the bat file and
  +                # keep the cmd process from terminating
  +                args = ["/K", str(activate_path)]
  +            completed_proc = subprocess.run([self.path, *args])
  +            return completed_proc.returncode
   
           import shlex
   
  @@ -81,9 +93,6 @@
           if self._name == "zsh":
               c.setecho(False)
   
  -        activate_script = self._get_activate_script()
  -        bin_dir = "Scripts" if WINDOWS else "bin"
  -        activate_path = env.path / bin_dir / activate_script
           c.sendline(f"{self._get_source_command()} {shlex.quote(str(activate_path))}")
   
           def resize(sig: Any, data: Any) -> None:
  @@ -103,6 +112,10 @@
               suffix = ".fish"
           elif self._name in ("csh", "tcsh"):
               suffix = ".csh"
  +        elif self._name in ("powershell", "pwsh"):
  +            suffix = ".ps1"
  +        elif self._name == "cmd":
  +            suffix = ".bat"
           else:
               suffix = ""
  
verification_info: {"golden_diff": "diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py\n--- a/src/poetry/utils/shell.py\n+++ b/src/poetry/utils/shell.py\n@@ -1,5 +1,6 @@\n import os\n import signal\n+import subprocess\n import sys\n \n from pathlib import Path\n@@ -67,8 +68,19 @@\n         return cls._shell\n \n     def activate(self, env: \"VirtualEnv\") -> Optional[int]:\n+        activate_script = self._get_activate_script()\n+        bin_dir = \"Scripts\" if WINDOWS else \"bin\"\n+        activate_path = env.path / bin_dir / activate_script\n+\n         if WINDOWS:\n-            return env.execute(self.path)\n+            if self._name in (\"powershell\", \"pwsh\"):\n+                args = [\"-NoExit\", \"-File\", str(activate_path)]\n+            else:\n+                # /K will execute the bat file and\n+                # keep the cmd process from terminating\n+                args = [\"/K\", str(activate_path)]\n+            completed_proc = subprocess.run([self.path, *args])\n+            return completed_proc.returncode\n \n         import shlex\n \n@@ -81,9 +93,6 @@\n         if self._name == \"zsh\":\n             c.setecho(False)\n \n-        activate_script = self._get_activate_script()\n-        bin_dir = \"Scripts\" if WINDOWS else \"bin\"\n-        activate_path = env.path / bin_dir / activate_script\n         c.sendline(f\"{self._get_source_command()} {shlex.quote(str(activate_path))}\")\n \n         def resize(sig: Any, data: Any) -> None:\n@@ -103,6 +112,10 @@\n             suffix = \".fish\"\n         elif self._name in (\"csh\", \"tcsh\"):\n             suffix = \".csh\"\n+        elif self._name in (\"powershell\", \"pwsh\"):\n+            suffix = \".ps1\"\n+        elif self._name == \"cmd\":\n+            suffix = \".bat\"\n         else:\n             suffix = \"\"\n", "issue": "Update prompt environment variable when opening shell\n<!--\r\n  Hi there! Thank you for wanting to make Poetry better.\r\n\r\n  Before you submit this; let's make sure of a few things.\r\n  Please make sure the following boxes are ticked if they are correct.\r\n  If not, please try and fulfill these first.\r\n-->\r\n\r\n<!-- Checked checkbox should look like this: [x] -->\r\n- [x] I have searched the [issues](https://github.com/sdispater/poetry/issues) of this repo and believe that this is not a duplicate.\r\n- [x] I have searched the [documentation](https://poetry.eustace.io/docs/) and believe that my question is not covered.\r\n\r\n## Feature Request\r\n<!-- Now feel free to write your idea for improvement. Thanks again \ud83d\ude4c \u2764\ufe0f -->\r\nWhen running `poetry shell` you have no idea your in the virtualenv or not. Please add the virtualenv's name to the $PROMPT or $PS1 variable.\n", "before_files": [{"content": "import os\nimport signal\nimport sys\n\nfrom pathlib import Path\nfrom typing import TYPE_CHECKING\nfrom typing import Any\nfrom typing import Optional\n\nimport pexpect\n\nfrom cleo.terminal import Terminal\nfrom shellingham import ShellDetectionFailure\nfrom shellingham import detect_shell\n\nfrom poetry.utils._compat import WINDOWS\n\n\nif TYPE_CHECKING:\n    from poetry.utils.env import VirtualEnv\n\n\nclass Shell:\n    \"\"\"\n    Represents the current shell.\n    \"\"\"\n\n    _shell = None\n\n    def __init__(self, name: str, path: str) -> None:\n        self._name = name\n        self._path = path\n\n    @property\n    def name(self) -> str:\n        return self._name\n\n    @property\n    def path(self) -> str:\n        return self._path\n\n    @classmethod\n    def get(cls) -> \"Shell\":\n        \"\"\"\n        Retrieve the current shell.\n        \"\"\"\n        if cls._shell is not None:\n            return cls._shell\n\n        try:\n            name, path = detect_shell(os.getpid())\n        except (RuntimeError, ShellDetectionFailure):\n            shell = None\n\n            if os.name == \"posix\":\n                shell = os.environ.get(\"SHELL\")\n            elif os.name == \"nt\":\n                shell = os.environ.get(\"COMSPEC\")\n\n            if not shell:\n                raise RuntimeError(\"Unable to detect the current shell.\")\n\n            name, path = Path(shell).stem, shell\n\n        cls._shell = cls(name, path)\n\n        return cls._shell\n\n    def activate(self, env: \"VirtualEnv\") -> Optional[int]:\n        if WINDOWS:\n            return env.execute(self.path)\n\n        import shlex\n\n        terminal = Terminal()\n        with env.temp_environ():\n            c = pexpect.spawn(\n                self._path, [\"-i\"], dimensions=(terminal.height, terminal.width)\n            )\n\n        if self._name == \"zsh\":\n            c.setecho(False)\n\n        activate_script = self._get_activate_script()\n        bin_dir = \"Scripts\" if WINDOWS else \"bin\"\n        activate_path = env.path / bin_dir / activate_script\n        c.sendline(f\"{self._get_source_command()} {shlex.quote(str(activate_path))}\")\n\n        def resize(sig: Any, data: Any) -> None:\n            terminal = Terminal()\n            c.setwinsize(terminal.height, terminal.width)\n\n        signal.signal(signal.SIGWINCH, resize)\n\n        # Interact with the new shell.\n        c.interact(escape_character=None)\n        c.close()\n\n        sys.exit(c.exitstatus)\n\n    def _get_activate_script(self) -> str:\n        if self._name == \"fish\":\n            suffix = \".fish\"\n        elif self._name in (\"csh\", \"tcsh\"):\n            suffix = \".csh\"\n        else:\n            suffix = \"\"\n\n        return \"activate\" + suffix\n\n    def _get_source_command(self) -> str:\n        if self._name in (\"fish\", \"csh\", \"tcsh\"):\n            return \"source\"\n        return \".\"\n\n    def __repr__(self) -> str:\n        return f'{self.__class__.__name__}(\"{self._name}\", \"{self._path}\")'\n", "path": "src/poetry/utils/shell.py"}]}