Windows Terminal: Open terminal in current folder via single command #886

Closed
opened 2026-01-30 22:08:14 +00:00 by claunia · 71 comments
Owner

Originally created by @nphmuller on GitHub (May 9, 2019).

Currently I can open cmd and powershell in the current folder via typing cmd or powershell in the address bar of explorer (which opens via CTRL+D, so it's really neat and quick).

It would be great if this was also possible with the new Windows Terminal. But since it's a Windows Store app I can't find an easy way to add it to PATH. It also doesn't respect the current folder when opening. It always starts in the default folder (C:\WINDOWS\system32 for cmd and ~ for Ubuntu).

It would be great if this was possible:

  • Make it possible to add Windows Terminal to PATH.
  • Open the command line in the current folder in Windows Terminal.

It would also be nice if it could be opened with a short command.
The executable currently is called WindowsTerminal. Would be nice if we could simply type something like term.

Originally created by @nphmuller on GitHub (May 9, 2019). Currently I can open cmd and powershell in the current folder via typing `cmd` or `powershell` in the address bar of explorer (which opens via CTRL+D, so it's really neat and quick). It would be great if this was also possible with the new Windows Terminal. But since it's a Windows Store app I can't find an easy way to add it to PATH. It also doesn't respect the current folder when opening. It always starts in the default folder (`C:\WINDOWS\system32` for cmd and `~` for Ubuntu). It would be great if this was possible: - Make it possible to add Windows Terminal to PATH. - Open the command line in the current folder in Windows Terminal. It would also be nice if it could be opened with a short command. The executable currently is called `WindowsTerminal`. Would be nice if we could simply type something like `term`.
claunia added the Resolution-Answered label 2026-01-30 22:08:14 +00:00
Author
Owner

@joandrsn commented on GitHub (May 9, 2019):

What happens if you use wt.exe ?

af7316c130/src/cascadia/CascadiaPackage/Package.appxmanifest (L51)

The alias should already launch a WindowsTerminal, but I'm not sure if it launches in the path that you specify

@joandrsn commented on GitHub (May 9, 2019): What happens if you use `wt.exe` ? https://github.com/microsoft/Terminal/blob/af7316c130059ba15fe16ff0d13608d956a2b449/src/cascadia/CascadiaPackage/Package.appxmanifest#L51 The alias should already launch a WindowsTerminal, but I'm not sure if it launches in the path that you specify
Author
Owner

@lennylxx commented on GitHub (May 9, 2019):

@joandrsn This is great, I didn't know. Thanks.

@lennylxx commented on GitHub (May 9, 2019): @joandrsn This is great, I didn't know. Thanks.
Author
Owner

@nphmuller commented on GitHub (May 9, 2019):

@joandrsn Thanks! It even launches in the current directory!

@nphmuller commented on GitHub (May 9, 2019): @joandrsn Thanks! It even launches in the current directory!
Author
Owner

@RehanSaeed commented on GitHub (Aug 30, 2019):

How do you pass a directory path to wt.exe. Something like this:

wt.exe "C:\GitHub"
@RehanSaeed commented on GitHub (Aug 30, 2019): How do you pass a directory path to wt.exe. Something like this: ``` wt.exe "C:\GitHub" ```
Author
Owner

@CEbbinghaus commented on GitHub (Sep 11, 2019):

Tried but Always opens in Default folder for both CMD and PowerShell.

I can open the WSL Ubuntu shell in the current folder with ubuntu run. but wt always opens in the default folder

@CEbbinghaus commented on GitHub (Sep 11, 2019): Tried but Always opens in Default folder for both CMD and PowerShell. I can open the WSL Ubuntu shell in the current folder with `ubuntu run`. but `wt` always opens in the default folder
Author
Owner

@DHowett-MSFT commented on GitHub (Sep 11, 2019):

Remove startingDirectory from your profiles.json.

@DHowett-MSFT commented on GitHub (Sep 11, 2019): Remove `startingDirectory` from your profiles.json.
Author
Owner

@mstyura commented on GitHub (Sep 19, 2019):

Hello @DHowett-MSFT,
is there a way to ask Windows Terminal open new tab in the same folder as current tab? I want the same behavior as exist on Mac OS X: https://apple.stackexchange.com/questions/178017/how-do-i-open-a-new-terminal-window-for-same-directory-as-the-current-window.
Thanks in advance!

@mstyura commented on GitHub (Sep 19, 2019): Hello @DHowett-MSFT, is there a way to ask `Windows Terminal` open new tab in the same folder as current tab? I want the same behavior as exist on `Mac OS X`: https://apple.stackexchange.com/questions/178017/how-do-i-open-a-new-terminal-window-for-same-directory-as-the-current-window. Thanks in advance!
Author
Owner

@MikenTNT commented on GitHub (Sep 25, 2019):

Remove startingDirectory from your profiles.json.

@DHowett-MSFT, this doesn't work in the latest version 0.5.2661.0 :(

@MikenTNT commented on GitHub (Sep 25, 2019): > Remove `startingDirectory` from your profiles.json. @DHowett-MSFT, this doesn't work in the latest version 0.5.2661.0 :(
Author
Owner

@retkowski commented on GitHub (Sep 25, 2019):

Remove startingDirectory from your profiles.json.

For me, it doesn't work either :(

@retkowski commented on GitHub (Sep 25, 2019): > Remove `startingDirectory` from your profiles.json. For me, it doesn't work either :(
Author
Owner

@zadjii-msft commented on GitHub (Sep 25, 2019):

As of v0.5, that actually won't work any longer. You'll need to set "startingDirectory": null for this to work actually. That fix regressed unintentionally in #2515.

@zadjii-msft commented on GitHub (Sep 25, 2019): As of v0.5, that actually won't work any longer. You'll need to set `"startingDirectory": null` for this to work actually. That fix regressed unintentionally in #2515.
Author
Owner

@itnavigate commented on GitHub (Sep 30, 2019):

I'd also like to open new tabs in the current directory

@itnavigate commented on GitHub (Sep 30, 2019): I'd also like to open new tabs in the current directory
Author
Owner

@payambordbar commented on GitHub (Oct 3, 2019):

As of v0.5, that actually won't work any longer. You'll need to set "startingDirectory": null for this to work actually. That fix regressed unintentionally in #2515.

@zadjii-msft , this doesn't work in v0.5.2681.0

@payambordbar commented on GitHub (Oct 3, 2019): > As of v0.5, that actually won't work any longer. You'll need to set `"startingDirectory": null` for this to work actually. That fix regressed unintentionally in #2515. @zadjii-msft , this doesn't work in v0.5.2681.0
Author
Owner

@mantasaudickas commented on GitHub (Oct 7, 2019):

As of v0.5, that actually won't work any longer. You'll need to set "startingDirectory": null for this to work actually. That fix regressed unintentionally in #2515.

Does not work with 0.5.2762.0 either..
I have tried removing value, setting to null.. both does not change anything..

@mantasaudickas commented on GitHub (Oct 7, 2019): > As of v0.5, that actually won't work any longer. You'll need to set `"startingDirectory": null` for this to work actually. That fix regressed unintentionally in #2515. Does not work with 0.5.2762.0 either.. I have tried removing value, setting to null.. both does not change anything..
Author
Owner

@DHowett-MSFT commented on GitHub (Oct 7, 2019):

To be clear, removing startingDirectory instead of setting it to null isn’t a feature that’s coming back; we are looking at alternative approaches regarding when exactly to apply startingDirectory, but the setting will always be able to be suppressed by setting it to null.

@DHowett-MSFT commented on GitHub (Oct 7, 2019): To be clear, _removing `startingDirectory` instead of setting it to `null`_ isn’t a feature that’s coming back; we are looking at alternative approaches regarding when exactly to apply startingDirectory, but the setting will always be able to be suppressed by setting it to null.
Author
Owner

@ozziepeeps commented on GitHub (Oct 11, 2019):

As of v0.5, that actually won't work any longer. You'll need to set "startingDirectory": null for this to work actually. That fix regressed unintentionally in #2515.

Does not work with 0.5.2762.0 either..
I have tried removing value, setting to null.. both does not change anything..

"startingDirectory": null works for me - it needs to be put under a specific profile, rather than being a root-level element

@ozziepeeps commented on GitHub (Oct 11, 2019): > > As of v0.5, that actually won't work any longer. You'll need to set `"startingDirectory": null` for this to work actually. That fix regressed unintentionally in #2515. > > Does not work with 0.5.2762.0 either.. > I have tried removing value, setting to null.. both does not change anything.. `"startingDirectory": null ` works for me - it needs to be put under a specific profile, rather than being a root-level element
Author
Owner

@piotrpalek commented on GitHub (Nov 18, 2019):

@DHowett-MSFT it seems to me that an approach of having settings in a config file (startingDirectory) which can be overriden by passing in command line params is pretty common in general. Maybe I'm not getting the issue here :)

@piotrpalek commented on GitHub (Nov 18, 2019): @DHowett-MSFT it seems to me that an approach of having settings in a config file (`startingDirectory`) which can be overriden by passing in command line params is pretty common in general. Maybe I'm not getting the issue here :)
Author
Owner

@DHowett-MSFT commented on GitHub (Nov 18, 2019):

If I recall the conversation from last month, it was:

Clearing the “startingDirectory” setting by deleting it from your user profile (in the specific case of the two or three default shipped profiles), instead of setting it to null to clear it, is not a feature that will be coming back.

#607 specifies that we will support command line arguments, one of which will be the starting directory override.

This seems to be in line with my understanding of your understanding of this conversation. 😄

@DHowett-MSFT commented on GitHub (Nov 18, 2019): If I recall the conversation from last month, it was: Clearing the “startingDirectory” setting by deleting it from your user profile (in the specific case of the two or three default shipped profiles), instead of setting it to `null` to clear it, is not a feature that will be coming back. #607 specifies that we will support command line arguments, one of which will be the starting directory override. This seems to be in line with my understanding of your understanding of this conversation. :smile:
Author
Owner

@torpederos commented on GitHub (Nov 22, 2019):

For me setting "startingDirectory": "." does the job.

@torpederos commented on GitHub (Nov 22, 2019): For me setting "startingDirectory": "." does the job.
Author
Owner

@carlinmack commented on GitHub (Nov 26, 2019):

is there another issue for having the terminal default open to say "%USERPROFILE%" but null if launched from windows explorer?

@carlinmack commented on GitHub (Nov 26, 2019): is there another issue for having the terminal default open to say `"%USERPROFILE%"` but `null` if launched from windows explorer?
Author
Owner

@Arcitec commented on GitHub (Dec 6, 2019):

@carlinmack I don't think that's entirely necessary.

  • The Windows Terminal defaults to the user's home directory if you launch it via the Start menu shortcut or via typing "wt" in Win+R. Which means that if you use "startingDirectory": "." they still open in the user's home folder (%USERPROFILE%).
  • If you launch wt from the Windows Explorer address bar, or via something like cmd.exe (or another shell) navigated to a certain folder, then the "startingDirectory": "." will ensure that Windows Terminal opens in the directory you were in.
  • However... Any additional tabs you open within the Windows Terminal session will open in the "current working dir" from the launch moment, which may be a minor annoyance.
@Arcitec commented on GitHub (Dec 6, 2019): @carlinmack I don't think that's entirely necessary. - The Windows Terminal defaults to the user's home directory if you launch it via the Start menu shortcut or via typing "wt" in Win+R. Which means that if you use `"startingDirectory": "."` they still open in the user's home folder (`%USERPROFILE%`). - If you launch wt from the Windows Explorer address bar, or via something like cmd.exe (or another shell) navigated to a certain folder, then the `"startingDirectory": "."` will ensure that Windows Terminal opens in the directory you were in. - However... Any additional tabs you open within the Windows Terminal session will open in the "current working dir" from the launch moment, which may be a minor annoyance.
Author
Owner

@kerams commented on GitHub (Feb 10, 2020):

The Windows Terminal defaults to the user's home directory if you launch it via the Start menu shortcut or via typing "wt" in Win+R. Which means that if you use "startingDirectory": "." they still open in the user's home folder (%USERPROFILE%).

It defaults to system32 in those case for me.

@kerams commented on GitHub (Feb 10, 2020): > The Windows Terminal defaults to the user's home directory if you launch it via the Start menu shortcut or via typing "wt" in Win+R. Which means that if you use "startingDirectory": "." they still open in the user's home folder (%USERPROFILE%). It defaults to system32 in those case for me.
Author
Owner

@charlyjose commented on GitHub (Feb 21, 2020):

Thanks @torpederos

"startingDirectory": "."
"startingDirectory": "%__CD__%"

Checked. Both works fine for me. My solution.

@RickStrahl have written a good blog regarding this issue. Check it out.

@charlyjose commented on GitHub (Feb 21, 2020): Thanks @torpederos "startingDirectory": "`.`" "startingDirectory": "%`__`CD`__`%" Checked. Both works fine for me. [My solution](https://github.com/charlyjose/wt). @RickStrahl have written a good blog regarding this issue. [Check it out](https://weblog.west-wind.com/posts/2019/Sep/03/Programmatically-Opening-Windows-Terminal-in-a-Specific-Folder).
Author
Owner

@ghost commented on GitHub (Apr 30, 2020):

In my case this worked.

"profiles":
    {
        "defaults":
        {
            "startingDirectory": "."
        },
@ghost commented on GitHub (Apr 30, 2020): In my case this worked. ```json "profiles": { "defaults": { "startingDirectory": "." }, ```
Author
Owner

@AndeYashwanth commented on GitHub (May 23, 2020):

"startingDirectory": "." works but when I open terminal from search it defaults to system32.
Is there any way to open in the user directory when the path is not specified?

@AndeYashwanth commented on GitHub (May 23, 2020): ```"startingDirectory": "."``` works but when I open terminal from search it defaults to system32. Is there any way to open in the user directory when the path is not specified?
Author
Owner

@manishprivet commented on GitHub (May 28, 2020):

"startingDirectory": "." works but when I open terminal from search it defaults to system32.
Is there any way to open in the user directory when the path is not specified?

I had the same problem. I fixed it by adding the following line at the end of my .bashrc file.

export CURR_DIRECTORY=`pwd`
if [ "$CURR_DIRECTORY" = "/mnt/c/WINDOWS/system32" ]; then
    cd ~
fi
@manishprivet commented on GitHub (May 28, 2020): > `"startingDirectory": "."` works but when I open terminal from search it defaults to system32. > Is there any way to open in the user directory when the path is not specified? I had the same problem. I fixed it by adding the following line at the end of my .bashrc file. ``` export CURR_DIRECTORY=`pwd` if [ "$CURR_DIRECTORY" = "/mnt/c/WINDOWS/system32" ]; then cd ~ fi ```
Author
Owner

@mrghofrani commented on GitHub (Jun 1, 2020):

Solution of @manishprivet was great, except that In order to work properly, I have changed the system32 to System32. It's a good idea to run pwd and copy the output.

@mrghofrani commented on GitHub (Jun 1, 2020): Solution of @manishprivet was great, except that In order to work properly, I have changed the `system32` to `System32`. It's a good idea to run `pwd` and copy the output.
Author
Owner

@AndeYashwanth commented on GitHub (Jun 1, 2020):

I found a workaround by adding "open terminal here" to right-click.

step-1:-
Remove the starting directory from the settings.json for all profiles.

step-2:-
Add the open terminal to right-click according to this post.
https://github.com/microsoft/terminal/issues/1060#issuecomment-497539461
I changed the 2nd registry value from @="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe" to @="C:\Users\[your username]\AppData\Local\Microsoft\WindowsApps\wt.exe -d ."

Behaviour after modifications:
So whenever I open terminal using search/taskbar/shortcut it will open in my user folder.
Whenever I want to open the terminal using the explorer, I just right-click and select Windows terminal here option.

Note 1: Don't forget to add -d . at the end of the second registry value, otherwise, this will not work.

Note 2: Typing wt in explorer bar still opens the terminal in system32. You should still type wt -d . if you want to open terminal in the current folder using the "explorer bar".

@AndeYashwanth commented on GitHub (Jun 1, 2020): I found a workaround by adding "open terminal here" to right-click. **step-1:-** Remove the starting directory from the settings.json for all profiles. **step-2:-** Add the open terminal to right-click according to this post. https://github.com/microsoft/terminal/issues/1060#issuecomment-497539461 I changed the 2nd registry value from ```@="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe"``` to ```@="C:\Users\[your username]\AppData\Local\Microsoft\WindowsApps\wt.exe -d ."``` **Behaviour after modifications:** So whenever I open terminal using search/taskbar/shortcut it will open in my user folder. Whenever I want to open the terminal using the explorer, I just right-click and select ```Windows terminal here``` option. Note 1: Don't forget to add ```-d .``` at the end of the second registry value, otherwise, this will not work. Note 2: Typing ```wt``` in explorer bar still opens the terminal in system32. You should still type ```wt -d .``` if you want to open terminal in the current folder using the "explorer bar".
Author
Owner

@LauKT commented on GitHub (Jun 1, 2020):

Just add

"startingDirectory": null

It works with wt V1.0 properly.

If you prefer making wt shown in SHIFT-Menu just like "Open PowerShell window here" or Open WSL options, you can merge this registry file to your Registry.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Open Windows Terminal here"
"ShowBasedOnVelocityId"=dword:00639bc8
"Extended"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\[YourUserName]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"

@LauKT commented on GitHub (Jun 1, 2020): Just add ```json "startingDirectory": null ``` It works with wt V1.0 properly. If you prefer making wt shown in **SHIFT-Menu** just like "Open PowerShell window here" or Open WSL options, you can merge this registry file to your Registry. ```registry Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\Background\shell\wt] @="Open Windows Terminal here" "ShowBasedOnVelocityId"=dword:00639bc8 "Extended"="" [HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command] @="C:\\Users\\[YourUserName]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe" ```
Author
Owner

@connorjak commented on GitHub (Jun 7, 2020):

Please note the startingDirectory parameter should go in this place in the JSON structure:

{
    //...

    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
            
            // Attempt to start in current directory
            // https://github.com/microsoft/terminal/issues/620
            "startingDirectory": "."
        }
    }
}
@connorjak commented on GitHub (Jun 7, 2020): Please note the `startingDirectory` parameter should go in this place in the JSON structure: ``` JSONC { //... "profiles": { "defaults": { // Put settings here that you want to apply to all profiles. // Attempt to start in current directory // https://github.com/microsoft/terminal/issues/620 "startingDirectory": "." } } } ```
Author
Owner

@nickraphael commented on GitHub (Jun 10, 2020):

I'm yet to see a solution that will do the following:

  1. Allow me to select a default directory when I open Terminal from start menu.
  2. When running wt.exe from explorer window will open Terminal to that directory.

Is this possible?

@nickraphael commented on GitHub (Jun 10, 2020): I'm yet to see a solution that will do the following: 1. Allow me to select a default directory when I open Terminal from start menu. 2. When running wt.exe from explorer window will open Terminal to that directory. Is this possible?
Author
Owner

@zadjii-msft commented on GitHub (Jun 10, 2020):

From my investigation, that wasn't something that was technically possible.

If you want both to work, you'll need to use wt -d . in the explorer address bar. This will let launching the Terminal from the start menu and the run box work the same as before, and still let you open the Terminal in the CWD in explorer

@zadjii-msft commented on GitHub (Jun 10, 2020): From [my investigation](https://github.com/microsoft/terminal/issues/878#issuecomment-538511693), that wasn't something that was technically possible. If you want both to work, you'll need to use `wt -d .` in the explorer address bar. This will let launching the Terminal from the start menu and the run box work the same as before, and still let you open the Terminal in the CWD in explorer
Author
Owner

@29kartik commented on GitHub (Jun 10, 2020):

From my initial exploration here is what I found based on https://docs.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows

Approach 1:

  1. Press WIN key + R
  2. Type wt -d D:\SomeDirectory

This will open up the default shell present in the settings.json with that directory
P.S. Choose path based on the OS of the shell in default

Approach 2:

  1. Go to the desired folder using the File Explorer
  2. In the address bar of the desired folder Type wt -d .
@29kartik commented on GitHub (Jun 10, 2020): From my initial exploration here is what I found based on https://docs.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows Approach 1: 1. Press WIN key + R 2. Type `wt -d D:\SomeDirectory` This will open up the default shell present in the settings.json with that directory P.S. Choose path based on the OS of the shell in default Approach 2: 1. Go to the desired folder using the File Explorer 2. In the address bar of the desired folder Type `wt -d .`
Author
Owner

@spookyuser commented on GitHub (Jun 11, 2020):

@AndeYashwanth That works perfectly, thank you. Now I can have it open in my user directory from the taskbar and only open in the current directory when I right click 😎

@spookyuser commented on GitHub (Jun 11, 2020): @AndeYashwanth That works perfectly, thank you. Now I can have it open in my user directory from the taskbar and only open in the current directory when I right click 😎
Author
Owner

@StJohn3D commented on GitHub (Jun 11, 2020):

Thanks @29kartik approach 1 worked for me. I was able to get GitKraken to use a custom terminal command of wt -d %d so that now it's terminal shortcut launches WT at the current repo's directory. 💯

@StJohn3D commented on GitHub (Jun 11, 2020): Thanks @29kartik approach 1 worked for me. I was able to get GitKraken to use a custom terminal command of `wt -d %d` so that now it's terminal shortcut launches WT at the current repo's directory. 💯
Author
Owner

@franzwcom commented on GitHub (Jun 15, 2020):

I've added this to open in this specific folder

 "startingDirectory": "C:\\webdev"
@franzwcom commented on GitHub (Jun 15, 2020): I've added this to open in this specific folder ```ssh "startingDirectory": "C:\\webdev" ```
Author
Owner

@kmantel commented on GitHub (Jun 17, 2020):

This is my take on it via context menu shortcut: https://gist.github.com/kmantel/9cd6bf9f0fb25694a5b08119817281b7

@kmantel commented on GitHub (Jun 17, 2020): This is my take on it via context menu shortcut: https://gist.github.com/kmantel/9cd6bf9f0fb25694a5b08119817281b7
Author
Owner

@kankri commented on GitHub (Aug 4, 2020):

@nickraphael:

I'm yet to see a solution that will do the following:

  1. Allow me to select a default directory when I open Terminal from start menu.
  2. When running wt.exe from explorer window will open Terminal to that directory.

Having this in settings.json:

{
    "profiles": {
        "defaults": {
            "startingDirectory": "."
        }
    }
}

makes Windows Terminal start in the current directory for me when launched from Explorer location box, win+r or from other programs (VS Code etc.). However, when starting from Start menu, either by searching or navigating to the shortcut, it starts in C:\WINDOWS\system32.

To fix the Start menu issue, I pinned a shortcut to wt.exe to the Start menu (where wt tells its location), renamed the shortcut to my liking and then modified it to have:

Start in: %USERPROFILE%

Now Windows Terminal starts in my home directory when launched from the Start menu.

It would be nice if Windows Terminal wouldn't change its directory by default to make it more transparent. There aren't many other programs which do that.

I'm also wondering if the shortcut to wt.exe could be made by the installer automatically.

@kankri commented on GitHub (Aug 4, 2020): @nickraphael: >I'm yet to see a solution that will do the following: > > 1. Allow me to select a default directory when I open Terminal from start menu. > 2. When running wt.exe from explorer window will open Terminal to that directory. Having this in `settings.json`: ```json { "profiles": { "defaults": { "startingDirectory": "." } } } ``` makes Windows Terminal start in the current directory for me when launched from Explorer location box, <kbd>win</kbd>+<kbd>r</kbd> or from other programs (VS Code etc.). However, when starting from Start menu, either by searching or navigating to the shortcut, it starts in `C:\WINDOWS\system32`. To fix the Start menu issue, I pinned a shortcut to `wt.exe` to the Start menu (`where wt` tells its location), renamed the shortcut to my liking and then modified it to have: Start in: %USERPROFILE% Now Windows Terminal starts in my home directory when launched from the Start menu. It would be nice if Windows Terminal wouldn't change its directory by default to make it more transparent. There aren't many other programs which do that. I'm also wondering if the shortcut to `wt.exe` could be made by the installer automatically.
Author
Owner

@frankitox commented on GitHub (Oct 19, 2020):

So, none of the above answers worked for my use case. What I'd like to do is open a new tab using alt+shift+- and keep the previous folder. I tried using null, "." and "%__CD__%" as values for "startingDirectory" in different places of the JSON. I'm using version 1.4.2652.0 of Windows Terminal Preview.

One nice solution would be to have a new option like "keepCurrentDirectoryOnNewTab": true or something like that. Other way (that Kitty uses) is having a special value called current when specifying the directory.

@frankitox commented on GitHub (Oct 19, 2020): So, none of the above answers worked for my use case. What I'd like to do is open a new tab using `alt+shift+-` and keep the previous folder. I tried using `null`, `"."` and `"%__CD__%"` as values for `"startingDirectory"` in different places of the JSON. I'm using version `1.4.2652.0` of Windows Terminal Preview. One nice solution would be to have a new option like `"keepCurrentDirectoryOnNewTab": true` or something like that. Other way (that Kitty uses) is having a special value called `current` when specifying the directory.
Author
Owner

@zadjii-msft commented on GitHub (Oct 19, 2020):

@frankitox You're probably interested in #3158 and the like 20 issues that are duped to that thread
image

There's been quite the discussion of why this is hard or nearly impossible to do correctly on windows.

@zadjii-msft commented on GitHub (Oct 19, 2020): @frankitox You're probably interested in #3158 and the like 20 issues that are duped to that thread ![image](https://user-images.githubusercontent.com/18356694/96502609-a6fbce00-1217-11eb-8444-ef68c2f4640a.png) There's been quite the discussion of why this is hard or nearly impossible to do correctly on windows.
Author
Owner

@baddate commented on GitHub (Oct 22, 2020):

VERSION: 1.3.2651.0

in my case it works.

    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
            "startingDirectory": "."
        },

also, you can use "startingDirectory": "%__CD__%"

@baddate commented on GitHub (Oct 22, 2020): VERSION: 1.3.2651.0 in my case it works. ``` "profiles": { "defaults": { // Put settings here that you want to apply to all profiles. "startingDirectory": "." }, ``` also, you can use `"startingDirectory": "%__CD__%"`
Author
Owner

@james-poulose commented on GitHub (Nov 14, 2020):

I am probably very late to the party, but in Windows 10 Pro 20H2, you can just type wt in the address bar and it will do the trick.

@james-poulose commented on GitHub (Nov 14, 2020): I am probably very late to the party, but in Windows 10 Pro 20H2, you can just type `wt` in the address bar and it will do the trick.
Author
Owner

@petref commented on GitHub (Nov 17, 2020):

How do you pass a directory path to wt.exe. Something like this:

wt.exe "C:\GitHub"

I don't know if you found -d and path

@petref commented on GitHub (Nov 17, 2020): > How do you pass a directory path to wt.exe. Something like this: > > ``` > wt.exe "C:\GitHub" > ``` I don't know if you found -d and path
Author
Owner

@Combo819 commented on GitHub (Nov 24, 2020):

wt -d .

works well in WSL2

@Combo819 commented on GitHub (Nov 24, 2020): ``` wt -d . ``` works well in WSL2
Author
Owner

@alexandremucci commented on GitHub (Nov 29, 2020):

You can set up the starting directory using your preferred address, either globally or for a specific profile. To have a context menu to open it in the current folder, create and save a .reg file with the content below. Ps.: change {USERNAME} to your username.


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\windowsterminal]
@="Windows Terminal Here"
[HKEY_CLASSES_ROOT\Directory\Background\shell\windowsterminal\command]
@="\"C:\\Users\\{USERNAME}\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe\" -d ."

Double click the saved file to add these entries to the registry.

@alexandremucci commented on GitHub (Nov 29, 2020): You can set up the starting directory using your preferred address, either globally or for a specific profile. To have a context menu to open it in the current folder, create and save a .reg file with the content below. Ps.: change {USERNAME} to your username. ``` Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\Background\shell\windowsterminal] @="Windows Terminal Here" [HKEY_CLASSES_ROOT\Directory\Background\shell\windowsterminal\command] @="\"C:\\Users\\{USERNAME}\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe\" -d ." ``` Double click the saved file to add these entries to the registry.
Author
Owner

@viceice commented on GitHub (Mar 22, 2021):

Does anybody know why "startingDirectory": "." in default profil is no longer working on 1.6.10571.0?

Also wt nt will open a new window instead of a new tab.

clicking the + button to open a new tab also no longer reuses the startup directory of the first tab. 😕

@viceice commented on GitHub (Mar 22, 2021): Does anybody know why `"startingDirectory": "."` in default profil is no longer working on 1.6.10571.0? Also `wt nt` will open a new window instead of a new tab. clicking the `+` button to open a new tab also no longer reuses the startup directory of the first tab. 😕
Author
Owner

@zadjii-msft commented on GitHub (Mar 22, 2021):

Does anybody know why "startingDirectory": "." in default profil is no longer working on 1.6.10571.0?

Nope, you should probably file a new issue so we can follow up with you and figure out what's going on

Also wt nt will open a new window instead of a new tab.

That's how it has always worked - in 1.7 there's windowingBehavior and --window <id> to help control this.

clicking the + button to open a new tab also no longer reuses the startup directory of the first tab. 😕

Pretty sure that's how it's always worked - it'll always use the startingDirectory of the default profile, and if your default profile's startingDirectory is ., then it'll use the directory the terminal was launched from.

@zadjii-msft commented on GitHub (Mar 22, 2021): > Does anybody know why `"startingDirectory": "."` in default profil is no longer working on 1.6.10571.0? > Nope, you should probably file a new issue so we can follow up with you and figure out what's going on > Also `wt nt` will open a new window instead of a new tab. > That's how it has always worked - in 1.7 there's `windowingBehavior` and `--window <id>` to help control this. > clicking the `+` button to open a new tab also no longer reuses the startup directory of the first tab. 😕 Pretty sure that's how it's always worked - it'll always use the `startingDirectory` of the default profile, and if your default profile's `startingDirectory` is `.`, then it'll use the directory the terminal was launched from.
Author
Owner

@viceice commented on GitHub (Mar 22, 2021):

Does anybody know why "startingDirectory": "." in default profil is no longer working on 1.6.10571.0?

Nope, you should probably file a new issue so we can follow up with you and figure out what's going on

Also wt nt will open a new window instead of a new tab.

That's how it has always worked - in 1.7 there's windowingBehavior and --window <id> to help control this.

clicking the + button to open a new tab also no longer reuses the startup directory of the first tab. 😕

Pretty sure that's how it's always worked - it'll always use the startingDirectory of the default profile, and if your default profile's startingDirectory is ., then it'll use the directory the terminal was launched from.

I'm using the context menu to open wt in a specific folder (using the entry generated by wt). That will open the first tab in that folder, but new tab will open in system32.

Before i used my own context menu entry:


$exe = (Get-Command wt).Source
$ico = Resolve-Path "$PSScriptRoot\wt.ico"

$title = "Windows Terminal here"

New-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere -Force
Set-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere $title
New-ItemProperty HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere -Name Icon -Value $ico -Force
New-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere\command -Force
Set-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere\command """$exe"" -d ""%L"""


New-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere -Force
Set-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere $title
New-ItemProperty HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere -Name Icon -Value $ico -Force
New-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere\command -Force
Set-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere\command "$exe"


# Currently not supported until v0.9
#Remove-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere -Force -Recurse
@viceice commented on GitHub (Mar 22, 2021): > > Does anybody know why `"startingDirectory": "."` in default profil is no longer working on 1.6.10571.0? > > Nope, you should probably file a new issue so we can follow up with you and figure out what's going on > > > Also `wt nt` will open a new window instead of a new tab. > > That's how it has always worked - in 1.7 there's `windowingBehavior` and `--window <id>` to help control this. > > > clicking the `+` button to open a new tab also no longer reuses the startup directory of the first tab. 😕 > > Pretty sure that's how it's always worked - it'll always use the `startingDirectory` of the default profile, and if your default profile's `startingDirectory` is `.`, then it'll use the directory the terminal was launched from. I'm using the context menu to open wt in a specific folder (using the entry generated by wt). That will open the first tab in that folder, but new tab will open in system32. Before i used my own context menu entry: ```pwsh $exe = (Get-Command wt).Source $ico = Resolve-Path "$PSScriptRoot\wt.ico" $title = "Windows Terminal here" New-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere -Force Set-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere $title New-ItemProperty HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere -Name Icon -Value $ico -Force New-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere\command -Force Set-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere\command """$exe"" -d ""%L""" New-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere -Force Set-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere $title New-ItemProperty HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere -Name Icon -Value $ico -Force New-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere\command -Force Set-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere\command "$exe" # Currently not supported until v0.9 #Remove-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere -Force -Recurse ```
Author
Owner

@zadjii-msft commented on GitHub (Mar 22, 2021):

Yep, that's exactly how it works. You might be interested in #8933

@zadjii-msft commented on GitHub (Mar 22, 2021): Yep, that's exactly how it works. You might be interested in #8933
Author
Owner

@kaaax0815 commented on GitHub (Apr 29, 2021):

I had the same problem. I fixed it by adding the following line at the end of my .bashrc file.

@manishprivet Is this possible in windows?

@kaaax0815 commented on GitHub (Apr 29, 2021): > I had the same problem. I fixed it by adding the following line at the end of my .bashrc file. @manishprivet Is this possible in windows?
Author
Owner

@manishprivet commented on GitHub (Apr 30, 2021):

I had the same problem. I fixed it by adding the following line at the end of my .bashrc file.

@manishprivet Is this possible in windows?

@kaaax0815 Yes this is for windows only

@manishprivet commented on GitHub (Apr 30, 2021): > > I had the same problem. I fixed it by adding the following line at the end of my .bashrc file. > > @manishprivet Is this possible in windows? @kaaax0815 Yes this is for windows only
Author
Owner

@kaaax0815 commented on GitHub (Apr 30, 2021):

@kaaax0815 Yes this is for windows only

@manishprivet But bashrc would be wsl not native windows. Or where should I put it

@kaaax0815 commented on GitHub (Apr 30, 2021): > @kaaax0815 Yes this is for windows only @manishprivet But bashrc would be wsl not native windows. Or where should I put it
Author
Owner

@manishprivet commented on GitHub (Apr 30, 2021):

@kaaax0815 Yes this is for windows only

@manishprivet But bashrc would be wsl not native windows. Or where should I put it

@kaaax0815 In the WSL's bashrc file actually

@manishprivet commented on GitHub (Apr 30, 2021): > > @kaaax0815 Yes this is for windows only > > @manishprivet But bashrc would be wsl not native windows. Or where should I put it @kaaax0815 In the WSL's bashrc file actually
Author
Owner

@kaaax0815 commented on GitHub (Apr 30, 2021):

@manishprivet the matter has resolved itself. I changed the cmd search shortcut to wt and this fixed the path problem

@kaaax0815 commented on GitHub (Apr 30, 2021): @manishprivet the matter has resolved itself. I changed the cmd search shortcut to wt and this fixed the path problem
Author
Owner

@KSneijders commented on GitHub (Jun 11, 2021):

You can now just go to settings -> profiles (Powershell / Command prompt).
And check the checkbox: 'Use parent process directory'

image

@KSneijders commented on GitHub (Jun 11, 2021): You can now just go to `settings -> profiles (Powershell / Command prompt)`. And check the checkbox: 'Use parent process directory' ![image](https://user-images.githubusercontent.com/32707500/121692065-fb65fd80-cac7-11eb-846a-99e2a73b1557.png)
Author
Owner

@rafapaulin commented on GitHub (Nov 1, 2021):

@KSneijders unfortunately we do not have that on wsl :(

@rafapaulin commented on GitHub (Nov 1, 2021): @KSneijders unfortunately we do not have that on wsl :(
Author
Owner

@rafapaulin commented on GitHub (Nov 1, 2021):

actually we do, but it does not work

@rafapaulin commented on GitHub (Nov 1, 2021): actually we do, but it does not work
Author
Owner

@rafapaulin commented on GitHub (Nov 1, 2021):

power shell also does not work

@rafapaulin commented on GitHub (Nov 1, 2021): power shell also does not work
Author
Owner

@pratikbarve09 commented on GitHub (Nov 12, 2021):

So, none of the above answers worked for my use case. What I'd like to do is open a new tab using alt+shift+- and keep the previous folder. I tried using null, "." and "%__CD__%" as values for "startingDirectory" in different places of the JSON. I'm using version 1.4.2652.0 of Windows Terminal Preview.

One nice solution would be to have a new option like "keepCurrentDirectoryOnNewTab": true or something like that. Other way (that Kitty uses) is having a special value called current when specifying the directory.

I'm using Windows Terminal v1.11.2921.0
this worked for me:

  1. in windows terminal, under default profile, add startingDirectory value to "."
  2. if you are going with explorer, in the address bar type "wt" and it will open your default profile in that directory or right-click and choose "open windows terminal here" option to open the default profile (if you have edited the registry for this)
  3. for every profile add a value of "startingDirectory" to "."
@pratikbarve09 commented on GitHub (Nov 12, 2021): > So, none of the above answers worked for my use case. What I'd like to do is open a new tab using `alt+shift+-` and keep the previous folder. I tried using `null`, `"."` and `"%__CD__%"` as values for `"startingDirectory"` in different places of the JSON. I'm using version `1.4.2652.0` of Windows Terminal Preview. > > One nice solution would be to have a new option like `"keepCurrentDirectoryOnNewTab": true` or something like that. Other way (that Kitty uses) is having a special value called `current` when specifying the directory. I'm using Windows Terminal v1.11.2921.0 this worked for me: 1. in windows terminal, under default profile, add startingDirectory value to "." 2. if you are going with explorer, in the address bar type "wt" and it will open your default profile in that directory or right-click and choose "open windows terminal here" option to open the default profile (if you have edited the registry for this) 3. for every profile add a value of "startingDirectory" to "."
Author
Owner

@krlvm commented on GitHub (Dec 17, 2021):

If anyone is looking for a solution without changing startingDirectory, I have placed such a file in %SystemRoot\System32 named wtx.cmd:

@ECHO off
wt -d .
exit /B !ERRORLEVEL!
@krlvm commented on GitHub (Dec 17, 2021): If anyone is looking for a solution without changing `startingDirectory`, I have placed such a file in `%SystemRoot\System32` named `wtx.cmd`: ```batch @ECHO off wt -d . exit /B !ERRORLEVEL! ```
Author
Owner

@AEROGU commented on GitHub (Jul 6, 2022):

Remove startingDirectory from your profiles.json.

Thanks @DHowett-MSFT, I was making VSCode when pressing ctrl+ñ the external console wt.exe appears, because the integrated one has problems with unicode in windows and, when I did it, it always started in my %USERPROFILE%, your solution worked, now runs in my project directory.

For those who are interested, I used wt --window 0 focus-tab so that if I already have a WindowsTerminal window open, it will be raised instead of creating another instance.

@AEROGU commented on GitHub (Jul 6, 2022): > Remove `startingDirectory` from your profiles.json. Thanks @DHowett-MSFT, I was making VSCode when pressing ctrl+ñ the external console `wt.exe` appears, because the integrated one has problems with unicode in windows and, when I did it, it always started in my %USERPROFILE%, your solution worked, now runs in my project directory. For those who are interested, I used `wt --window 0 focus-tab` so that if I already have a WindowsTerminal window open, it will be raised instead of creating another instance.
Author
Owner

@ErcinDedeoglu commented on GitHub (Aug 5, 2022):

You can now just go to settings -> profiles (Powershell / Command prompt). And check the checkbox: 'Use parent process directory'

image

thank you! this solution is the best solution. and still working

@ErcinDedeoglu commented on GitHub (Aug 5, 2022): > You can now just go to `settings -> profiles (Powershell / Command prompt)`. And check the checkbox: 'Use parent process directory' > > ![image](https://user-images.githubusercontent.com/32707500/121692065-fb65fd80-cac7-11eb-846a-99e2a73b1557.png) thank you! this solution is the best solution. and still working
Author
Owner

@sanayvarghese commented on GitHub (Oct 9, 2022):

Current directory in Windows terminal using explorer

You can open current directory in Windows terminal using explorer using
wt -d .

@sanayvarghese commented on GitHub (Oct 9, 2022): ## Current directory in Windows terminal using explorer You can open current directory in Windows terminal using explorer using `wt -d .`
Author
Owner

@jleaders commented on GitHub (Mar 29, 2023):

Please add wt -d to wt -h
image

@jleaders commented on GitHub (Mar 29, 2023): Please add `wt -d` to `wt -h` ![image](https://user-images.githubusercontent.com/2430917/228442998-c7b1ce83-b4ec-4987-8eea-33f23105c9ba.png)
Author
Owner

@zadjii-msft commented on GitHub (Mar 29, 2023):

@jleaders the help text is understandably a little confusing in this particular case, because of the implicit new-tab subcommand that's used when no subcommand is provided explicitly. You'll note, -d is under wt new-tab --help

image

It's just that CLI11 doesn't know how to wire the args for new-tab up to the help message for the root command's help text.

@zadjii-msft commented on GitHub (Mar 29, 2023): @jleaders the help text is understandably a little confusing in this particular case, because of the implicit `new-tab` subcommand that's used when no subcommand is provided explicitly. You'll note, `-d` is under `wt new-tab --help` ![image](https://user-images.githubusercontent.com/18356694/228525053-a9cb63f5-6fd5-4e2a-94be-8fcaa9266856.png) It's just that CLI11 doesn't know how to wire the args for `new-tab` up to the help message for the root command's help text.
Author
Owner

@filiSpinelli commented on GitHub (Mar 31, 2023):

@nphmuller Referring to the first main discussion of thus topic, you can open a new terminal windows, placed in the current working folder, by typing "cmd" and press Enter in the url ##bar.
image

@filiSpinelli commented on GitHub (Mar 31, 2023): @nphmuller Referring to the first main discussion of thus topic, you can open a new terminal windows, placed in the current working folder, by typing "cmd" and press Enter in the url ##bar. ![image](https://user-images.githubusercontent.com/119928321/229056976-f14129eb-9e1a-45ef-b130-d1c6f0fd3726.png)
Author
Owner

@loan-mgt commented on GitHub (Oct 29, 2023):

solution wt -d .

@loan-mgt commented on GitHub (Oct 29, 2023): solution `wt -d .`
Author
Owner

@6philipp9 commented on GitHub (Feb 9, 2024):

[ Settings : "Startup" → "standard terminal application" ] change this to windows terminal -> All Terminals open now in the Windows Terminal.

@6philipp9 commented on GitHub (Feb 9, 2024): [ Settings : "Startup" → "standard terminal application" ] change this to windows terminal -> All Terminals open now in the Windows Terminal.
Author
Owner

@candrapersada commented on GitHub (Sep 23, 2024):

how to use %USERPROFILE% in start menu if use Use parent process directory for Open terminal in current folder via wt

@candrapersada commented on GitHub (Sep 23, 2024): how to use `%USERPROFILE%` in start menu if use `Use parent process directory` for Open terminal in current folder via `wt`
Author
Owner

@chrisrodrigue commented on GitHub (Oct 11, 2024):

The default behavior of cmd.exe, powershell.exe, and pwsh.exe is to start in the current directory when invoked from any shell or the File Explorer address bar, or to open in %USERPROFILE% when invoked elsewhere (such as Run or Start Menu shortcuts).

wt.exe deviates from this behavior. If you have the starting directory set to ., it will still start in C:\Windows\System32 when invoked from a shortcut or the Start Menu. Why?

For those frustrated by this, here's a script you can put on your PATH (or in C:\Windows\System32) that works from any shell, File Explorer, or Run.

wtd opens a normal window in the current directory.

wtd a opens an elevated window in the current directory.

wtd.bat:

@echo off
if "%1"=="a" (
    net session >nul 2>&1 || (
        powershell -c "start -v runas '%~f0'"
        exit
    )
)
wt -d .
@chrisrodrigue commented on GitHub (Oct 11, 2024): The default behavior of `cmd.exe`, `powershell.exe`, and `pwsh.exe` is to start in the current directory when invoked from any shell or the File Explorer address bar, or to open in `%USERPROFILE%` when invoked elsewhere (such as Run or Start Menu shortcuts). `wt.exe` deviates from this behavior. If you have the starting directory set to `.`, it will still start in `C:\Windows\System32` when invoked from a shortcut or the Start Menu. Why? For those frustrated by this, here's a script you can put on your PATH (or in `C:\Windows\System32`) that works from any shell, File Explorer, or Run. `wtd` opens a normal window in the current directory. `wtd a` opens an elevated window in the current directory. wtd.bat: ```cmd @echo off if "%1"=="a" ( net session >nul 2>&1 || ( powershell -c "start -v runas '%~f0'" exit ) ) wt -d . ```
Author
Owner

@DHowett commented on GitHub (Oct 11, 2024):

When you have Terminal set as your default console host, you can also just go back to launching cmd, powershell or pwsh directly from the file explorer address bar or whichever shell...

@DHowett commented on GitHub (Oct 11, 2024): When you have Terminal set as your default console host, you can also just go back to launching `cmd`, `powershell` or `pwsh` directly from the file explorer address bar or whichever shell...
Author
Owner

@chrisrodrigue commented on GitHub (Oct 11, 2024):

When you have Terminal set as your default console host, you can also just go back to launching cmd, powershell or pwsh directly from the file explorer address bar or whichever shell...

Yeah but all of those are more verbose than typing wt.

Besides, how would you launch Git Bash? Users should be able to invoke their default console host in the current directory when calling wt from that directory in File Explorer.

And it should never, ever default to opening in a system directory such as System32.

@chrisrodrigue commented on GitHub (Oct 11, 2024): > When you have Terminal set as your default console host, you can also just go back to launching `cmd`, `powershell` or `pwsh` directly from the file explorer address bar or whichever shell... Yeah but all of those are more verbose than typing `wt`. Besides, how would you launch Git Bash? Users should be able to invoke their default console host in the current directory when calling `wt` from that directory in File Explorer. And it should never, ever default to opening in a system directory such as `System32`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#886