Set environment variable in current shell from child process #23011

Open
opened 2026-01-31 08:29:53 +00:00 by claunia · 0 comments
Owner

Originally created by @peakschris on GitHub (Mar 11, 2025).

Description of the new feature

We launch a python CLI from windows terminal. As a result of certain CLI actions, we want the windows terminal to set certain environment variables as soon as the python CLI command finishes. I understand that this is impossible when launching python from CMD. However, maybe there is some trick to allow it when launching python from Windows Terminal.

We have discarded the option of wrapping the python CLI in a bat or cmd as then we end up with the dreaded 'Terminate (Y/N)' prompt on Ctrl-C.

My hope is that Windows Terminal has some kind of scripting support such that the python subprocess can add an envvar in its parent shell via some kind of API call.

Any other ideas very welcome!

Proposed technical implementation details

No response

Originally created by @peakschris on GitHub (Mar 11, 2025). ### Description of the new feature We launch a python CLI from windows terminal. As a result of certain CLI actions, we want the windows terminal to set certain environment variables as soon as the python CLI command finishes. I understand that this is impossible when launching python from CMD. However, maybe there is some trick to allow it when launching python from Windows Terminal. We have discarded the option of wrapping the python CLI in a bat or cmd as then we end up with the dreaded 'Terminate (Y/N)' prompt on Ctrl-C. My hope is that Windows Terminal has some kind of scripting support such that the python subprocess can add an envvar in its parent shell via some kind of API call. Any other ideas very welcome! ### Proposed technical implementation details _No response_
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23011