Repository: xonsh/xonsh

Issue:
add --prompt arg to vox new
If #4670 is merged, xonsh becomes prompt aware and therefore it might be in the interest of symmetric behaviour to add the functionality to vox, to pass `--prompt` through to venv.

## Expected Behavior

`vox new --prompt "some custom name" myvenv` will be passed through to `venv.EnvBuilder` and therefore set prompt in `<venv dir>/<myvenv>/pyvenvf.cfg`

## Current Behavior

`vox new --prompt ...` is an unrecognized argument.

## For community
⬇️  **Please click the 👍 reaction instead of leaving a `+1` or 👍  comment**



Discussion:

Resolving patch:
diff --git a/xontrib/vox.py b/xontrib/vox.py
--- a/xontrib/vox.py
+++ b/xontrib/vox.py
@@ -87,6 +87,7 @@ def new(
         packages: xcli.Annotated[tp.Sequence[str], xcli.Arg(nargs="*")] = (),
         requirements: xcli.Annotated[tp.Sequence[str], xcli.Arg(action="append")] = (),
         link_project_dir=False,
+        prompt: "str|None" = None,
     ):
         """Create a virtual environment in $VIRTUALENV_HOME with python3's ``venv``.
 
@@ -114,6 +115,8 @@ def new(
             The argument value is passed to ``pip -r`` to be installed.
         link_project_dir: -l, --link, --link-project
             Associate the current directory with the new environment.
+        prompt: --prompt
+            Provides an alternative prompt prefix for this environment.
         """
 
         print("Creating environment...")
@@ -128,6 +131,7 @@ def new(
             symlinks=symlinks,
             with_pip=(not without_pip),
             interpreter=interpreter,
+            prompt=prompt,
         )
         if link_project_dir:
             self.project_set(name)
diff --git a/xontrib/voxapi.py b/xontrib/voxapi.py
--- a/xontrib/voxapi.py
+++ b/xontrib/voxapi.py
@@ -139,6 +139,7 @@ def create(
         system_site_packages=False,
         symlinks=False,
         with_pip=True,
+        prompt=None,
     ):
         """Create a virtual environment in $VIRTUALENV_HOME with python3's ``venv``.
 
@@ -157,8 +158,9 @@ def create(
             environment.
         with_pip : bool
             If True, ensure pip is installed in the virtual environment. (Default is True)
+        prompt: str
+            Provides an alternative prompt prefix for this environment.
         """
-
         if interpreter is None:
             interpreter = _get_vox_default_interpreter()
             print(f"Using Interpreter: {interpreter}")
@@ -176,7 +178,14 @@ def create(
                 )
             )
 
-        self._create(env_path, interpreter, system_site_packages, symlinks, with_pip)
+        self._create(
+            env_path,
+            interpreter,
+            system_site_packages,
+            symlinks,
+            with_pip,
+            prompt=prompt,
+        )
         events.vox_on_create.fire(name=name)
 
     def upgrade(self, name, symlinks=False, with_pip=True, interpreter=None):
@@ -219,6 +228,9 @@ def upgrade(self, name, symlinks=False, with_pip=True, interpreter=None):
             "symlinks": symlinks,
             "with_pip": with_pip,
         }
+        prompt = cfgops.get("prompt")
+        if prompt:
+            flags["prompt"] = prompt.lstrip("'\"").rstrip("'\"")
         # END things we shouldn't be doing.
 
         # Ok, do what we came here to do.
@@ -233,6 +245,7 @@ def _create(
         symlinks=False,
         with_pip=True,
         upgrade=False,
+        prompt=None,
     ):
         version_output = sp.check_output(
             [interpreter, "--version"], stderr=sp.STDOUT, text=True
@@ -255,8 +268,10 @@ def _create(
             with_pip,
             upgrade,
         ]
-        cmd = [arg for arg in cmd if arg]  # remove empty args
+        if prompt and module == "venv":
+            cmd.extend(["--prompt", prompt])
 
+        cmd = [arg for arg in cmd if arg]  # remove empty args
         logging.debug(cmd)
 
         return_code = sp.call(cmd)


Test patch:
diff --git a/tests/test_vox.py b/tests/test_vox.py
--- a/tests/test_vox.py
+++ b/tests/test_vox.py
@@ -368,6 +368,7 @@ def no_change(self, *_):
                     "--requirements",
                     "-t",
                     "--temp",
+                    "--prompt",
                 }
             ),
         ),