Option to remember starting directory from the last tab/session #15923

Closed
opened 2026-01-31 04:52:18 +00:00 by claunia · 9 comments
Owner

Originally created by @working-name on GitHub (Nov 18, 2021).

Description of the new feature/enhancement

Hello, I come from iTerm2 on macOS and several linux distros where the most useful part about starting a new tab or window or splitting the current view horizontally or vertically is to be able to be right back where you were in the previous session.

I don't know if this use case is all that unique given the ubiquitous availability of this behavior on other terminal emulators, so I think it would be a step forward.

https://user-images.githubusercontent.com/16505052/142466163-574d807d-f6ee-49c4-9b56-061cfb1516ec.mp4

Originally created by @working-name on GitHub (Nov 18, 2021). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 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 <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> Hello, I come from iTerm2 on macOS and several linux distros where the most useful part about starting a new tab or window or splitting the current view horizontally or vertically is to be able to be right back where you were in the previous session. I don't know if this use case is all that unique given the ubiquitous availability of this behavior on other terminal emulators, so I think it would be a step forward. https://user-images.githubusercontent.com/16505052/142466163-574d807d-f6ee-49c4-9b56-061cfb1516ec.mp4
claunia added the Issue-FeatureResolution-Duplicate labels 2026-01-31 04:52:18 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Nov 18, 2021):

This has been discussed numerous times across the repo.

Generally, this is /dup #3158

@zadjii-msft commented on GitHub (Nov 18, 2021): This has been discussed numerous times across the repo. * #3158 * #8166 * #766 * There's the [`duplicateTab` action](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions#duplicate-tab) * the [duplicatePane action](https://docs.microsoft.com/en-us/windows/terminal/panes#duplicating-a-pane) * There's the duplicate tab and split pane menu items which will duplicate by default: ![image](https://user-images.githubusercontent.com/18356694/142469359-47309c1b-e1d9-4d18-9f3b-74e50f93295a.png) Generally, this is /dup #3158
Author
Owner

@ghost commented on GitHub (Nov 18, 2021):

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 (Nov 18, 2021): 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

@working-name commented on GitHub (Nov 18, 2021):

This has been discussed numerous times across the repo.

No resolution here, other than what seems like a bunch of workarounds, among which using a different terminal emulator altogether :)

Again, more workarounds, no solution.

Apparently available in beta releases but this is not a similar issue to what I'm asking at all.

This does not duplicate CWD as well, but does duplicate title and such. Running 1.11.2921.0 which is your latest official release.

Settings JSON contains the code as described, however, when using the shortcut I get the same behavior as above: something is duplicated but CWD is not part of it.

  • There's the duplicate tab and split pane menu items which will duplicate by default:
    image

This does the same thing as above - fails to duplicate CWD.

Generally, this is /dup #3158

@working-name commented on GitHub (Nov 18, 2021): > This has been discussed numerous times across the repo. > > * [Open new terminal tab in same directory as existing tab (OSC 7?) #3158](https://github.com/microsoft/terminal/issues/3158) No resolution here, other than what seems like a bunch of workarounds, among which using a different terminal emulator altogether :) > * [Consider using OSC 9;9 to inform Windows Terminal about CWD #8166](https://github.com/microsoft/terminal/issues/8166) Again, more workarounds, no solution. > * [Enable Terminal to persist / restore instance settings #766](https://github.com/microsoft/terminal/issues/766) Apparently available in beta releases but this is not a similar issue to what I'm asking at all. > * There's the [`duplicateTab` action](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions#duplicate-tab) This does not duplicate CWD as well, but does duplicate title and such. Running 1.11.2921.0 which is your latest official release. > * the [duplicatePane action](https://docs.microsoft.com/en-us/windows/terminal/panes#duplicating-a-pane) Settings JSON contains the code as described, however, when using the shortcut I get the same behavior as above: something is duplicated but CWD is not part of it. > * There's the duplicate tab and split pane menu items which will duplicate by default: > ![image](https://user-images.githubusercontent.com/18356694/142469359-47309c1b-e1d9-4d18-9f3b-74e50f93295a.png) This does the same thing as above - fails to duplicate CWD. > > Generally, this is /dup #3158
Author
Owner

@working-name commented on GitHub (Nov 18, 2021):

Tested 1.12.2931.0, same behavior - no CWD duplication through any of the aforementioned methods.

The "start where we left off" functionality also fails to maintain each tab's prior CWD, it just loads whatever is set as the default. Pretty useless for now.

@working-name commented on GitHub (Nov 18, 2021): Tested `1.12.2931.0`, same behavior - no CWD duplication through any of the aforementioned methods. The "start where we left off" functionality also fails to maintain each tab's prior CWD, it just loads whatever is set as the default. Pretty useless for now.
Author
Owner

@zadjii-msft commented on GitHub (Nov 18, 2021):

Those threads go into quite a lot of detail - you need to configure your shell to emit information to the Terminal about what the working directory is. You can use the OSC9;9 sequence to emit a Windows path, and then all the duplicate actions will be able to use that path.

The Terminal can't just magically determine the path of the commandline application for a variety of reasons that are detailed in #3158. Most significantly - PowerShell doesn't even change its own CWD, so trying to get the CWD from the attached application automagically will not work more often than it does 😅.

@zadjii-msft commented on GitHub (Nov 18, 2021): Those threads go into quite a lot of detail - **you need to configure your shell to emit information to the Terminal about what the working directory is**. You can use the `OSC9;9` sequence to emit a Windows path, and then all the duplicate actions will be able to use that path. The Terminal can't just magically determine the path of the commandline application for a variety of reasons that are detailed in #3158. Most significantly - PowerShell doesn't even change its own CWD, so trying to get the CWD from the attached application automagically will _not_ work more often than it _does_ 😅.
Author
Owner

@working-name commented on GitHub (Nov 18, 2021):

Oh I see, sorry, I come from macOS and linux which seems to "magically" have that part figured out without me adding stuff to .bashrc. My bad.

So I tried this thing and that won't do. If I simply try to export the variable in bash and change -m to -u to get the linux path which is what I'm trying to preserve, not SMB path to the directory shared from the VM controlled by wsl2... ( 🙄 ) - it just exits windows terminal. All of it.🤣

Also no idea what "ctrl +d" is supposed to do by default if not duplicate tab. I did not override the shortcut and it doesn't appear in the settings JSON but it closes the current tab when pressed.

So in your comment from 2020 you expressed dissatisfaction with people who are not willing to read through hundreds of comments across several threads - it's just A LOT to go through, and if you have no clue what OSC is, that's not helpful 😞. I skimmed through the links you posted above, and stopped where there was some code block. But that's about it, the rest of the conversation about OSC and different implementations in others OSes are well above my head.

You also mentioned that the team had then found a solution that you were happy with. Would you happen to know if that's the same as the stuff above? Is it posted anywhere?

https://user-images.githubusercontent.com/16505052/142484163-57cd2dbe-7abe-4b53-8ab7-75fa7347cabd.mp4

@working-name commented on GitHub (Nov 18, 2021): Oh I see, sorry, I come from macOS and linux which seems to "magically" have that part figured out without me adding stuff to .bashrc. My bad. So I tried [this thing](https://github.com/microsoft/terminal/issues/3158#issuecomment-907201734) and that won't do. If I simply try to export the variable in bash and change -m to -u to get the linux path which is what I'm trying to preserve, not SMB path to the directory shared from the VM controlled by wsl2... ( 🙄 ) - it just exits windows terminal. All of it.🤣 Also no idea what "ctrl +d" is supposed to do by default if not duplicate tab. I did not override the shortcut and it doesn't appear in the settings JSON but it closes the current tab when pressed. So in your [comment from 2020 ](https://github.com/microsoft/terminal/issues/3158#issuecomment-727026693) you expressed dissatisfaction with people who are not willing to read through hundreds of comments across several threads - it's just A LOT to go through, and if you have no clue what OSC is, that's not helpful 😞. I skimmed through the links you posted above, and stopped where there was some code block. But that's about it, the rest of the conversation about OSC and different implementations in others OSes are well above my head. You also mentioned that the team had then found a solution that you were happy with. Would you happen to know if that's the same as the stuff above? Is it posted anywhere? https://user-images.githubusercontent.com/16505052/142484163-57cd2dbe-7abe-4b53-8ab7-75fa7347cabd.mp4
Author
Owner

@zadjii-msft commented on GitHub (Nov 23, 2021):

Sorry, we've been meaning to write a tutorial on that for a while now, just never had the time. I wrote up a guide over at https://github.com/MicrosoftDocs/terminal/pull/449/files. That might help explain what's all needed to get this to work.

@zadjii-msft commented on GitHub (Nov 23, 2021): Sorry, we've been meaning to write a tutorial on that for a while now, just never had the time. I wrote up a guide over at https://github.com/MicrosoftDocs/terminal/pull/449/files. That might help explain what's all needed to get this to work.
Author
Owner

@kudorgyozo commented on GitHub (Jun 15, 2023):

This application is pretty much useless without this feature. I will still need to use ConEmu it seems.

@kudorgyozo commented on GitHub (Jun 15, 2023): This application is pretty much useless without this feature. I will still need to use ConEmu it seems.
Author
Owner

@DHowett commented on GitHub (Jun 15, 2023):

You are welcome to use whatever terminal emulator you would like on Windows.

@DHowett commented on GitHub (Jun 15, 2023): You are welcome to use whatever terminal emulator you would like on Windows.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15923