Windows Terminal session restore is not remembering the last directory that was set in each tab #18890

Closed
opened 2026-01-31 06:27:19 +00:00 by claunia · 4 comments
Owner

Originally created by @cyclr-adrian on GitHub (Nov 14, 2022).

Windows Terminal version

1.15.2875.0

Windows build number

10.0.22621.0

Other Software

I did have Oh-My-Posh module loading in via PowerShell profile, but I have since commented out that module from loading and running to eliminate it from this issue.

Steps to reproduce

Pre-Requisites

In your Windows Terminal Settings page set the following:

  1. Settings => Startup => When Terminal Starts set value to Open windows from previous session.
  2. The PowerShell profile you are using has a startingDirectory set e.g. "startingDirectory": "%USERPROFILE%"

Steps

  1. Load 2 PowerShell tabs in Windows Terminal
  2. Rename the tabs Tab 1 and Tab 2
  3. In Tab 2 change the directory so that it is different to the directory in Tab 1.
  4. Close Windows Terminal
  5. Re-Open Windows Terminal

Expected Behavior

When Re-Opening Windows Terminal Tab 1 and Tab 2 are restored with their tab names (Tab 1 and Tab 2) plus the initial directory in each tab is the same as it was when the previous Windows Terminal session was closed.

Actual Behavior

When Re-Opening Windows Terminal Tab 1 and Tab 2 are restored with their tab names (Tab 1 and Tab 2) however the initial directory in each tab is NOT the same as it was when the previous Windows Terminal session was closed, but tabs appear to have the same directory set.

I have tried changing the startingDirectory for the profile I was using from "startingDirectory": "%USERPROFILE%" to "startingDirectory": null but it makes no difference.

Originally created by @cyclr-adrian on GitHub (Nov 14, 2022). ### Windows Terminal version 1.15.2875.0 ### Windows build number 10.0.22621.0 ### Other Software I did have Oh-My-Posh module loading in via PowerShell profile, but I have since commented out that module from loading and running to eliminate it from this issue. ### Steps to reproduce #### Pre-Requisites In your Windows Terminal Settings page set the following: 1. `Settings` => `Startup` => `When Terminal Starts` set value to `Open windows from previous session`. 2. The PowerShell profile you are using has a `startingDirectory` set e.g. `"startingDirectory": "%USERPROFILE%"` #### Steps 1. Load 2 PowerShell tabs in Windows Terminal 3. Rename the tabs `Tab 1` and `Tab 2` 4. In `Tab 2` change the directory so that it is different to the directory in `Tab 1`. 5. Close Windows Terminal 6. Re-Open Windows Terminal ### Expected Behavior When Re-Opening Windows Terminal `Tab 1` and `Tab 2` are restored with their tab names (`Tab 1` and `Tab 2`) plus the initial directory in each tab is the same as it was when the previous Windows Terminal session was closed. ### Actual Behavior When Re-Opening Windows Terminal `Tab 1` and `Tab 2` are restored with their tab names (`Tab 1` and `Tab 2`) however the initial directory in each tab is NOT the same as it was when the previous Windows Terminal session was closed, but tabs appear to have the same directory set. I have tried changing the `startingDirectory` for the profile I was using from `"startingDirectory": "%USERPROFILE%"` to `"startingDirectory": null` but it makes no difference.
claunia added the Issue-QuestionNeeds-TriageIssue-BugResolution-Answered labels 2026-01-31 06:27:20 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Nov 14, 2022):

Did you make sure you've actually configured your shell to tell the Terminal what the CWD is?

Refer to: Opening a tab or pane in the same directory in Windows Terminal.

@zadjii-msft commented on GitHub (Nov 14, 2022): Did you make sure you've actually configured your shell to tell the Terminal what the CWD is? Refer to: [Opening a tab or pane in the same directory in Windows Terminal](https://docs.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory).
Author
Owner

@cyclr-adrian commented on GitHub (Nov 14, 2022):

I've just tried coping in the prompt function from powershell-with-posh-git to configure CWD on PowerShell with posh-git.

This does and doesn't work for my scenario. It works to remember the previous CWD for each tab when startingDirectory is set to null.

I am also using oh-my-posh to format the PowerShell prompt on top of posh-git and with the prompt function in my PowerShell profile I lose all of my oh-my-posh look and feel.

@cyclr-adrian commented on GitHub (Nov 14, 2022): I've just tried coping in the `prompt` function from [powershell-with-posh-git](https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory#powershell-with-posh-git) to configure `CWD` on PowerShell with posh-git. This does and doesn't work for my scenario. It works to remember the previous `CWD` for each tab when `startingDirectory ` is set to `null`. I am also using oh-my-posh to format the PowerShell prompt on top of posh-git and with the `prompt` function in my PowerShell profile I lose all of my oh-my-posh look and feel.
Author
Owner

@cyclr-adrian commented on GitHub (Nov 14, 2022):

I think I have it working now with oh-my-posh too.

I've set the startingDirectory to null and added "pwd": "osc99" to my on-my-posh config as stated here

@cyclr-adrian commented on GitHub (Nov 14, 2022): I think I have it working now with oh-my-posh too. I've set the `startingDirectory` to null and added `"pwd": "osc99"` to my on-my-posh config as stated [here](https://ohmyposh.dev/docs/configuration/overview#general-settings)
Author
Owner

@tommai78101 commented on GitHub (Nov 13, 2025):

I've set the startingDirectory to null and added "pwd": "osc99" to my on-my-posh config as stated here

The link is down. Do you happen to have an alternate mirror?

@tommai78101 commented on GitHub (Nov 13, 2025): > I've set the `startingDirectory` to null and added `"pwd": "osc99"` to my on-my-posh config as stated [here](https://ohmyposh.dev/docs/configuration/overview#general-settings) The link is down. Do you happen to have an alternate mirror?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18890