Update PATH Environment Variable without restarting terminal #8515

Closed
opened 2026-01-31 01:31:24 +00:00 by claunia · 4 comments
Owner

Originally created by @jch-code on GitHub (May 23, 2020).

Description of the new feature/enhancement

Whenever something new is added to the path environment variable, the user has to close/re-open terminal for it to update. It would be a convenient feature if this change could be detected and updated without restarting the application.

Proposed technical implementation details

I believe this is could be roughly accomplished with the following steps

  • Listen to the WM_SETTINGCHANGE message.

  • Grab the path from registry @HKEY_CURRENT_USER\Environment &&
    @HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

  • Grab the local PATH with getenv_s() / GetEnvironmentVariable()

  • Check for changes between the two

  • If changes are detected, update the local PATH with the new values with _putenv_s() / SetEnvironmentVariable()

  • Reflect these changes in each PowerShell or Command Prompt tab with Get/SetEnvironmentVariable() calls in each child process

I am fairly inexperienced with C++, but would like to attempt this implementation myself if the idea well recieved

Originally created by @jch-code on GitHub (May 23, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement Whenever something new is added to the path environment variable, the user has to close/re-open terminal for it to update. It would be a convenient feature if this change could be detected and updated without restarting the application. # Proposed technical implementation details I believe this is could be roughly accomplished with the following steps - Listen to the WM_SETTINGCHANGE message. - Grab the path from registry @HKEY_CURRENT_USER\Environment && @HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment - Grab the local PATH with getenv_s() / GetEnvironmentVariable() - Check for changes between the two - If changes are detected, update the local PATH with the new values with _putenv_s() / SetEnvironmentVariable() - Reflect these changes in each PowerShell or Command Prompt tab with Get/SetEnvironmentVariable() calls in each child process I am fairly inexperienced with C++, but would like to attempt this implementation myself if the idea well recieved
claunia added the Issue-FeatureResolution-Duplicate labels 2026-01-31 01:31:24 +00:00
Author
Owner

@DHowett commented on GitHub (May 25, 2020):

Thanks @JoshHenryJC! I would love to see an implementation of this. We're already tracking it in /dup #1125 -- if you want to work on it, feel free!

@DHowett commented on GitHub (May 25, 2020): Thanks @JoshHenryJC! I would love to see an implementation of this. We're already tracking it in /dup #1125 -- if you want to work on it, feel free!
Author
Owner

@ghost commented on GitHub (May 25, 2020):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (May 25, 2020): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@DHowett commented on GitHub (May 25, 2020):

There's some work to be done to plumb the window message down from IslandWindow/BaseWindow/AppHost (WindowsTerminal C++ project) into the Application layer (TerminalAppLib C++ Project)

@DHowett commented on GitHub (May 25, 2020): There's some work to be done to plumb the window message down from IslandWindow/BaseWindow/AppHost (WindowsTerminal C++ project) into the Application layer (TerminalAppLib C++ Project)
Author
Owner

@jch-code commented on GitHub (May 26, 2020):

@DHowett Thanks for the reply, I will take a look over at the original issue and see what I can come up with!

@jch-code commented on GitHub (May 26, 2020): @DHowett Thanks for the reply, I will take a look over at the original issue and see what I can come up with!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8515