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

Preserve virtualenv prompt when duplicating panes #14620

Closed
brupelo opened this issue Dec 31, 2022 · 3 comments
Closed

Preserve virtualenv prompt when duplicating panes #14620

brupelo opened this issue Dec 31, 2022 · 3 comments
Labels
Issue-Question For questions or discussion Needs-Tag-Fix Doesn't match tag requirements Resolution-Answered Related to questions that have been answered

Comments

@brupelo
Copy link

brupelo commented Dec 31, 2022

Consider this docs section https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory , I've already tried
to change the prompt env var to $e]9;9;$P$e\$P$G and works fairly ok. There is a catch though... let's say you've activated a python
virtualenv and you duplicate a pane... while the new environment (path + env.vars) will be inherited the prompt won't be the same than
before, is there any workaround for this one?

In conemu you'd have this nice behaviour out of the box.

Example when spawning this command

    {
        "command": 
        {
            "action": "splitPane",
            "split": "down",
            "splitMode": "duplicate"
        },
        "keys": "ctrl+shift+o"
    },

image

as you can see the duplicated bottom pane won't have the (venv) in the prompt

@brupelo brupelo added the Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs label Dec 31, 2022
@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Dec 31, 2022
@zadjii-msft
Copy link
Member

This is kinda a Hard problem. The Terminal can't really know about the env vars of the child subprocesses like that. (especially consider a scenario like ssh).

The closest we'll be able to do on that front is probably something like #2785, to have a set of environment variables in the settings for the profile manually.

Alternatively, you could just make a specific profile for that specific virtual environment, with the commandline something like cmd /k path/to/activate.bat.

In conemu you'd have this nice behaviour out of the box.

I'd be curious how they accomplish that without hooks of some sort - are they like, reporting every environment variable change up to the Terminal some how? That'd be... impractical, and impossible for CMD. Maybe that's a shell feature, of something like cmder? Maybe that's just a visual artifact, and not actually a full clone? Maybe they're just blindly copying the env vars from the first attached process to duplicated processes? That seems like a heuristic to me though

@zadjii-msft zadjii-msft added the Resolution-Answered Related to questions that have been answered label Jan 3, 2023
@brupelo
Copy link
Author

brupelo commented Jan 4, 2023

Mmm, I understand what you're saying there... In any case, I'd just like to know what's the best practice/feature to use here with wt.

Consider this scenario, having many dozens of python repos (if not hundreds) each one with their own virtualenv. Obviously it'd be nice having a plugin in your favourite text editor (vscode, sublime_text, atom, put_your_favourite_here) where you'd be able directly to spawn/activate your venv in wt, right? I mean, with conemu I had coded this sort of plugin in the past and it was pretty handy.

I'm thinking... is it possible to have "parametrized profiles"? Ie. can you inject external parameters to the profile? That way you'd be able to reuse the same profile amongst different venvs. Just thinking loud here.

Anyway, later on I'll play around with conemu and share my findings here... But what you're saying seems plausible and maybe conemu is using some sort of heuristic at the end of the day that won't work in the general case.

Here's a little example of creating/activating/splitting_horizontally/splitting_vertically in conemu though (vc=virtualenv creation, va=virtualenv activation)

image

@carlos-zamora carlos-zamora added Issue-Question For questions or discussion and removed Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jan 18, 2023
@carlos-zamora
Copy link
Member

We're keeping the discussion about parameterized profiles in #5571. We'd definitely like to make this easier, so feel free to chip in over there. We'd love to hear what you come up with 😊.

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Question For questions or discussion Needs-Tag-Fix Doesn't match tag requirements Resolution-Answered Related to questions that have been answered
Projects
None yet
Development

No branches or pull requests

3 participants