Feature Request: Preserve Python Virtual Environment and Working Directory on "Duplicate Tab" #23322

Closed
opened 2026-01-31 08:38:51 +00:00 by claunia · 3 comments
Owner

Originally created by @mriamnobody on GitHub (May 31, 2025).

Description of the new feature

The current "Duplicate Tab" functionality in Windows Terminal does not fully replicate the existing session. Two critical issues are observed:

  1. Working Directory Not Preserved
    When duplicating a tab, the new tab defaults to the user’s home directory (e.g., C:\Users\Username) rather than maintaining the working directory of the original tab.

Expected Behavior:
The duplicated tab should open in the same working directory as the tab it was duplicated from — this is especially important when working across deep project structures.

  1. Virtual Environment Context Not Preserved
    If a Python virtual environment (e.g., via venv or conda) is activated in the original tab, the duplicated tab does not retain this activation. It launches a plain shell session, requiring the environment to be manually reactivated.

Expected Behavior:
The new tab should inherit the activated environment context, mirroring the exact state of the original session.

This enhancement would greatly benefit developers and power users who frequently work in isolated environments and deep directory structures. Thank you for the ongoing development and great work on Windows Terminal!

Proposed technical implementation details

No response

Originally created by @mriamnobody on GitHub (May 31, 2025). ### Description of the new feature The current "Duplicate Tab" functionality in Windows Terminal does not fully replicate the existing session. Two critical issues are observed: 1. Working Directory Not Preserved When duplicating a tab, the new tab defaults to the user’s home directory (e.g., C:\Users\Username) rather than maintaining the working directory of the original tab. Expected Behavior: The duplicated tab should open in the same working directory as the tab it was duplicated from — this is especially important when working across deep project structures. 2. Virtual Environment Context Not Preserved If a Python virtual environment (e.g., via venv or conda) is activated in the original tab, the duplicated tab does not retain this activation. It launches a plain shell session, requiring the environment to be manually reactivated. Expected Behavior: The new tab should inherit the activated environment context, mirroring the exact state of the original session. This enhancement would greatly benefit developers and power users who frequently work in isolated environments and deep directory structures. Thank you for the ongoing development and great work on Windows Terminal! ### Proposed technical implementation details _No response_
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-Fix labels 2026-01-31 08:38:52 +00:00
Author
Owner

@achaljhawar commented on GitHub (Jun 1, 2025):

Hi can I work on this issue?

@achaljhawar commented on GitHub (Jun 1, 2025): Hi can I work on this issue?
Author
Owner

@lhecker commented on GitHub (Jun 2, 2025):

Working Directory Not Preserved

Have you set up your shell with OSC 9;9? See here: https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory

Virtual Environment Context Not Preserved

The terminal has practically no idea what you're running inside your shell. (And if it did, that would be quite the violation of trust.) As such it also doesn't know about your venv.

You can create a custom terminal profile that spawns you in the right directory with the right activation.

@lhecker commented on GitHub (Jun 2, 2025): > Working Directory Not Preserved Have you set up your shell with `OSC 9;9`? See here: https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory > Virtual Environment Context Not Preserved The terminal has practically no idea what you're running inside your shell. (And if it did, that would be quite the violation of trust.) As such it also doesn't know about your venv. You can create a custom terminal profile that spawns you in the right directory with the right activation.
Author
Owner

@DHowett commented on GitHub (Jun 4, 2025):

Alas, without some additional setup on your site this isn't going to be something Terminal can support.

Though if I may recommend a workaround: if you set up your virtual environment in your profile command line, duplicating a tab with that profile will carry along the venv activation. 🙂

@DHowett commented on GitHub (Jun 4, 2025): Alas, without some additional setup on your site this isn't going to be something Terminal can support. Though if I may recommend a workaround: if you set up your virtual environment _in your profile command line,_ duplicating a tab with that profile will carry along the venv activation. 🙂
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23322