Skip to content

Feature Request: Option to open new tabs in the same directory as the current tab #1437

Closed

Description

Summary of the new feature/enhancement

Very often when I'm working on a project, I want to open multiple tabs in the same directory. For example, for a web React project, I might want one tab for npm start, another for npm test --watch, and probably keep another around for various console commands I want to run (like git). It'd be very convenient to cd into my project directory and then just hit Ctrl-T a few times to open up more tabs in that project directory.

Instead, each tab current seems to be opened in the normal "startingDirectory", which is %USERPROFILE% by default, so you have to cd into the desired working directory for every new tab.

Activity

  1. added
    Issue-Feature
    on Jun 22, 2019
  2. ghost added
    Needs-Triage
    on Jun 22, 2019
  3. ghost added
    Needs-Tag-Fix
    on Jun 22, 2019
  4. DHowett-MSFT commented on Jun 24, 2019

    @DHowett-MSFT
    Contributor

    This is a "hard problem".. Technically, Terminal can't know the working directory of the process hosted inside it. This will be easier with #1131, but still "hard" for shells that don't actually set the working directory. PowerShell, for example, doesn't set the working directory!

  5. Jaykul commented on Jun 26, 2019

    @Jaykul
    Contributor

    Yeah, I always set the working directory in my PowerShell prompt function, because I can't understand why it doesn't do that on it's own ...

    But certainly it's tricky or impossible when some tabs are going to be purely remote (e.g. azshell).

    Maybe a solution would be to have a command line that could be run to start a new tab, and which would therefore know which directory it was running in?

  6. DHowett-MSFT commented on Jun 27, 2019

    @DHowett-MSFT
    Contributor

    On account of this one isn't possible in the general sense (for all types of connections, and all types of applications), I'm going to close it out. Sorry.

  7. added
    Product-Terminal
    Resolution-Won't-Fix
    Area-Interaction
    and removed
    Needs-Triage
    on Jun 27, 2019
  8. ghost removed
    Needs-Tag-Fix
    on Jun 27, 2019
  9. jarrodek commented on Aug 6, 2019

    @jarrodek

    This is disappointing. As a person with Linux background staring a new tab in a directory of previously selected tab is a normal thing. When working on a project I often need 2-3 tabs running stuff from the project. For a developer UX I would reconsider how to incorporate this behavior.
    I am trying to switch from Ubuntu to Windows for some time now and the only blocker left is usable console which is at leas as good as Bash. I don't feel that current release is as close.

  10. FXschwartz commented on Aug 20, 2019

    @FXschwartz

    Same as Paweł Uchida-Psztyć (@jarrodek) I'm coming from a Linux background trying to make the 100% switch to Windows.

    Really the only thing that was keeping me from it was the console. This new console is so far incredible and makes me super excited for the future of developing on Windows.

    Being able to

    1. Open a console
    2. Go to the working project directory
    3. Duplicate tab (with directory path) multiple times

    is something I do multiple times daily.

    Obviously, not a deal-breaker but would be absolutely incredible to have.

  11. dallonf commented on Aug 20, 2019

    @dallonf
    Author

    What are some ways this could work in a narrow use case? I'm personally fine if I can't duplicate an ssh tab or something like that, but for the common case of having a cmd/PowerShell/WSL terminal open and just wanting another one, it'd be very useful.

  12. davidhewitt commented on Oct 4, 2019

    @davidhewitt

    Also coming from a linux background, it's very helpful to be able to quickly open console tabs in the same directory. (It's disruptive to thinking to have to cd to some folder far from the terminal default when you want to briefly run a new command while some other long-lived command is running in your existing terminal.)

    I understand it can't work in all cases, but I'd love to contribute a PR where the existing ctrl+shift+d shortcut can preserve the working directory in cases where Terminal can detect the working directory.

    Only blocker to me submitting that PR is it doesn't seem obvious to me how to inspect the current working directory of a child process using the Windows APIs (equivalent of Linux's /proc/<PID>/cwd)! If anyone is able to suggest a method to me for that bit, I would happily do the rest.

  13. zadjii-msft commented on Oct 4, 2019

    @zadjii-msft
    Member

    I'd certainly review a PR that enabled this :)

    I remain worried that this will not work more often than it will work, but if we have a prototype, then it'll certainly be easier to make the call.

    Unfortunately, I don't really know how to get the working dir of another process myself. Presumably there must be a way... Dustin L. Howett (MSFT) (@DHowett-MSFT) thoughts?

  14. added
    Help Wanted
    on Nov 1, 2019
  15. rigwild commented on Apr 6, 2020

    @rigwild

    Any news on this ? This feature would be really useful.

  16. zadjii-msft commented on Apr 8, 2020

    @zadjii-msft
    Member

    rigwild I'd follow #3158 - that issue actually has a bit more detail on how such a feature might actually be possible to implement, so we've been using that one to track this feature.

  17. slon872 commented on Feb 1, 2021

    @slon872

    Suppose I run wt nt command from Windows Terminal.
    Child wt process can determine current directory and environment.
    Can it communicate with parent wt to open new tab in it instead of launching new terminal?

  18. zadjii-msft commented on Feb 1, 2021

    @zadjii-msft
    Member

    slon872 You might be interested in #4472, #5000, #8135, and #8898.

  19. zadjii-msft commented on May 18, 2021

    @zadjii-msft
    Member

    davidhiber Oh man, you'd be so interested in #8933. Feel free to continue the discussion in that thread.

  20. michaldudak commented on Jun 23, 2021

    @michaldudak

    Could it be achieved by allowing to run custom code in the 'source' tab to find out the CWD in a way specific to the shell? This could be specified per profile, so each shell could have its own method of determining the working directory.

  21. leon-strong commented on Oct 8, 2021

    @leon-strong

    For those coming here after the fact this acheived pretty much what i wanted (ctrl-shift-d to work as expected):

    Add this to your .bashrc

    export PROMPT_COMMAND='printf "\e]9;9;%s\e\" "$(wslpath -m "$PWD")"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-InteractionHelp WantedIssue-FeatureProduct-TerminalResolution-Won't-Fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions