Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open different shell in same directory #10232

Open
ghost opened this issue May 27, 2021 · 14 comments
Open

Open different shell in same directory #10232

ghost opened this issue May 27, 2021 · 14 comments
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Milestone

Comments

@ghost
Copy link

ghost commented May 27, 2021

Description of the new feature/enhancement

Sometimes, it so happens that I am in (lets say) powershell, and i am working on something, and i change directory to some location, and i find myself in need of a different shell for some reason. Just as an example, maybe i have to run a bash script present in that directory using Git Bash / Msys.

Asked this on reddit and @zadjii-msft asked to open an issue here

Proposed technical implementation details (optional)

No idea

@ghost ghost added Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels May 27, 2021
@skyline75489
Copy link
Collaborator

I have read the reddit post. This is possible and was actually implemented at the early days of #8166 when we were still trying to make OSC 7 work. Later reusing the CWD was limited to only duplicating tabs/panes, to prevent the feature from being too aggressive. Maybe we can add an option for folks who do love to reuse CWD for every tab created.

@mveril
Copy link

mveril commented May 27, 2021

I have read the reddit post. This is possible and was actually implemented at the early days of #8166 when we were still trying to make OSC 7 work. Later reusing the CWD was limited to only duplicating tabs/panes, to prevent the feature from being too aggressive. Maybe we can add an option for folks who do love to reuse CWD for every tab created.

I think it could be also a command in the command palette

@Vendetta8247
Copy link

Vendetta8247 commented May 27, 2021

This proposal is exactly the first thing I noticed "missing" when working on the new Terminal (just installed today and wasn't sure if I just didn't dive too deep). My personal use case: I'm working on Windows and writing a tool using bash and perl scripts. Still I prefer managing git through PowerShell (and access to files as well) and use cmd for local management inside Windows with the long familiar commands. Usually I just open Terminal as WSL but when I do commits or other stuff it's just easier to Shift+Right Click and open Powershell from the menu rather than opening a new tab and navigating into the directory. And IMO it defeats the purpose of having multiple different terminals inside one window. No matter how convenient it sounds (and in general it is very convenient) but in this case it's just not the most optimal way.

Also - the best possible scenario would be having these option:

  • set default dir of opening new window to the same as the currently opened terminal's dir
  • add an action to have an opportunity to open new tab in the same dir or in a default dir

@zadjii-msft
Copy link
Member

Hmmmmmmmmmm.

Now that I'm thinking about this, and comparing more with the rest of the repo, this might be an argument in favor of option 1 in #9957. We want to duplicate the path, but change the profile.

Oh no, wait it might be more complicated than that. It's "mode: duplicatePath", not duplicateProfile. Hmm.

@zadjii-msft
Copy link
Member

  • set default dir of opening new window to the same as the currently opened terminal's dir

oh boy that seems awfully specific - the new window duplicates the existing window's CWD? I'm cool doing this with a new tab, but the window seems like it might be confusing.

I even typed up an issue like this in the past, but I don't think I ever posted it

Add a setting to default the new tab button to "duplicate tab" instead of "open default profile"

Maybe that applies to the splitPane actions as well?

Is this just asking for "toolbar customization" though? Should this be an extension? How would we let an extension do that?

Would they get at the tab row, hide the new tab button, then add their own split button, with the same new tab menu, but with duplicateTab bound instead?

I think on discussion, we thought that this made a good extension candidate, but those are also 12+mos away, so maybe we should revisit

  • add an action to have an opportunity to open new tab in the same dir or in a default dir

Like, as a prompt? Like a different version of #3586? Otherwise you can of course just use duplicateTab or newTab today

  • (this is very theoretical) to have an opportunity to open a new tab for existing terminal window from Right clicking inside the folder - same as you can open Terminal now, but to add an option "Open as a new tab in Terminal)

That's over in #7071

@Vendetta8247
Copy link

oh boy that seems awfully specific - the new window duplicates the existing window's CWD? I'm cool doing this with a new tab, but the window seems like it might be confusing.

I'm so sorry for the confusion, I actually meant a new Tab. Was just in a rush to get my vision out 😒
I'm not sure how other people manage their terminals as I'm still a rookie in this, but I usually prefer having a:

  1. "group" of terminals for one specific task/folder. It would either be one project with a need of different terminals or subfolders open in tabs.
  2. Having a "git" terminal window with multiple repositories in tabs.

In first case I would definitely prefer to have tabs open in the same folder and then navigating to subfolder. Or simply opening a WSL/cmd/gitbash in the same folder. As you can see - it's pretty apparent why having a current folder option would be benefitial

In second case I would just open a new window - as it's working now.

That's over in #7071

This is kind of off-topic for this issue so I'll stop about that but yes, indeed. Excuse me for that as I haven't noticed the setting as I'm really really new to this Terminal

@orcmid
Copy link

orcmid commented Jun 15, 2021

It strikes me that terminal is not at the layer that knows another shell instance's Current Working Directory. I assume the shell tied to the terminal (tab) via stdin, stdout, and stderr that has such information, not WT. And the shell (and any other command-line app) might not be designed to detect wiring to WT and Terminal Tabs at all.

A shell's ability to Start an asynchronous console application might be helpful, although having that wired to a new tab sort of reduces to the previously-unsolved problem.

@TBBle
Copy link

TBBle commented Jun 15, 2021

This is actually the original request in #3158, but since #3158 (comment) where I called out the next step, that ticket has been filled with people working out how to emit OSC 9;9 in their particular shell environment, so it might make sense to mark that ticket as "Done, but for duplicate/split-duplicate tabs" and work against this ticket for "New tab/pane" support.

@orcmid Windows Terminal uses the OSC 9;9 command to know the current working directory, so that part's already done, except you have to teach your shells to emit it.

So this use-case is mostly about how we apply that knowledge to "New Tab", or "Split Tab (Not duplicate)", since just changing the default behaviour with no recourse would probably be surprising, while "Duplicate Tab" and "Duplicate Pane" carrying the CWD is pretty hard to disagree with.

@zadjii-msft
Copy link
Member

work against this ticket for "New tab/pane" support.

I'm sold. I'll stick it on the backlog. We'll have to come up with some sort of sensible setting for this. Maybe something like an enum - useTheStartingDirectory|useTheCWD|useTheTerminalsCWD, idk.

@zadjii-msft zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. labels Jul 6, 2021
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jul 6, 2021
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Jul 6, 2021
@zadjii-msft zadjii-msft removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Jul 6, 2021
@sheikalthaf
Copy link

@zadjii-msft Any update on this. I regularly duplicate the tab with same directory? But it is very hard to type every time the directory path. I really miss this feature from linux terminal

@TBBle
Copy link

TBBle commented Sep 3, 2021

@sheikalthaf: If you're duplicating the tab, it should already be keeping the current working directory as of Windows Terminal 1.6, if you have OSC 9;9 set up.

If you don't have OSC 9;9 set up, then the docs are a bit sparse (MicrosoftDocs/terminal#285) but there's a bunch of examples in #3158 comments for now.

@s-celles
Copy link

I'm also looking for a way to duplicate a tab and keep existing current working directory

 cd my_path

for each duplicated tab is just an extra step which could be avoid.

This behavior should be "out of the box" when installing new version of Terminal

@TBBle
Copy link

TBBle commented Oct 21, 2021

@scls19fr You're commenting on a ticket about new tabs or splits, not duplicating tabs or splits. Duplicating tabs is #3158, and that's already as done as possible in Windows Terminal; to be truly out-of-the-box, you need your shell to be updated to send the OSC 9;9 information so that Windows Terminal knows your "current working directory", e.g., for PowerShell there's a ticket open at PowerShell/PowerShell#15469 requesting this.

In the meantime, every shell I've come across has had a mechanism to let the user hook something to send that information, and there's a ton of recipes in the history #3158, and eventually, someone will document it nicely in MicrosoftDocs/terminal#285.

@0xdw
Copy link

0xdw commented Feb 18, 2022

I would suggest something like this?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

9 participants