33

As most of you know, it is possible to open a new Command Line in the current folder from the file explorer. For this you have to write 'cmd' in the folder path.

Is there a way to do this with the new Windows Terminal (Preview) yet? As this is currently my preferred shell.

Keimeno
  • 441
  • 1
  • 4
  • 5

7 Answers7

55

You can try this command in the folder path:

wt -d .

source

EDIT: Microsoft mentions the previous command in one of their videos alongside with many interesting features of Windows Terminal 1.0

Alex R.
  • 650
  • 1
  • 5
  • 5
  • 3
    This should be the accepted answer. Maybe terminal has changed since that one was chosen. – SixOThree Apr 15 '20 at 19:46
  • This is great, but when I open a new tab it doesn't share the same starting directory. Is there any way to change this? – David Callanan Jul 12 '20 at 08:59
  • 1
    @DavidCallanan Up until now, that's not posible. Every time you open a tab the terminal reads the startingDirectory that is set via the settings.json (see Edward answer below if you are unfamiliar). You can only change that for now. There is a request in here: https://github.com/microsoft/terminal/issues/3158 if you want to follow. Also, at the very bottom, one guy also suggests a function that changes the startingDirectory to cwd and then you can open a new tab. – Alex R. Jul 12 '20 at 23:03
50

To fix this:

  • Open Windows Terminal
  • Click the down arrow in the toolbar to get the menu and select "Settings"
  • Update your profiles.json defaults so that all shells starting directory is the current directory

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

From at least v0.9.433.0 on Windows 10 onwards the default value for "startingDirectory" in defaults.json on my machine is "%USERPROFILE%", which means typing "wt" in an explorer window opens in your home directory, not the current folder.

Edward
  • 509
  • 1
  • 4
  • 2
  • 2
    This should be the accepted answer! – Jérôme MEVEL Oct 15 '20 at 08:49
  • how do you know the answer? – Ooker Oct 06 '21 at 15:32
  • I did not find the profiles.json but found a setting in the UI. v1.12 at least has a UI to change this. Ctrl+, (Settings) > Defaults > uncheck `Use parent process directory` > enter `.` as starting directory. – bugybunny Mar 17 '22 at 12:46
  • For the people who can't find where the settings.json, for me at least, it's in: %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\ – rminaj Jun 15 '23 at 01:12
24

Simply type in wt in the address bar and it will open the command prompt with the path to your current folder already set. Make sure that your settings do not overwrite startingDirectory.

enter image description here

Ramhound
  • 41,734
  • 35
  • 103
  • 130
Marek Ozana
  • 372
  • 2
  • 2
  • 1
    Please edit your answer to indicate the exact requirement for this to work. It does not work on Windows 10 version 1903 (18362.356) – Ramhound Sep 22 '19 at 09:31
  • What exactly does not work? Is the issue with terminal not starting at all, or with the directory being different then expected? – Marek Ozana Sep 22 '19 at 12:17
  • All you need to know is that it doesn’t do what your animation does. So there is obviously a requirement for this to work. – Ramhound Sep 22 '19 at 14:15
  • Works perfectly for me, thanks for sharing your answer @MarekOzana. And Ramhound it works for me, although I have the same Version with the exact same build number. – Keimeno Sep 22 '19 at 16:41
  • 4
    When I do this, WT starts up a PowerShell instance _in its default starting directory_ rather than in the directory I've been viewing in Explorer. [EDITED to add:] This turns out, not very surprisingly, to be because my WT config specifies a startingDirectory. @Ramhound you might want to check that if you haven't already. – Gareth McCaughan Nov 27 '19 at 12:49
  • I don't have any `startingDirectory` in my Windows terminal `settings.json` file. This answer simply doesn't work out of the box and I believe requires a special configuration. I would downvote if I had enough reputation – Jérôme MEVEL Oct 15 '20 at 08:47
  • On my Windows 10 this does not work. Launches a search for "wt" – eshwar Nov 03 '20 at 02:35
  • Doesn't work for me wither... Explorer shows an error that C:\Users\\AppData\Local\Microsoft\WindowsApps\wt.exe does not exist. – nsimeonov Jun 01 '21 at 01:29
  • it seems like this is a bug from WT. I downvoted this answer a while ago, obviously this didn't work back then. But now I try the same method and it works for me – Ooker Feb 06 '22 at 08:23
  • 1
    This does indeed work. You just need to make sure a `startingDirectory` is not set in the config file *or* the default config file. In my case, it was in the default config (Command Palette > Open default settings file). To override it, I added `startingDirectory: null` under `profiles > defaults` in the `settings.json` file and now it works as expected. – Arshia001 May 13 '22 at 05:32
2

For quite some time, there is a PowerShell module called OpenHere that gives you granular options to control this functionality.

All you need is to copy paste this into PowerShell with elevated rights:

Install-Module -Name OpenHere; Import-Module -Name OpenHere

and start to explore the Set-OpenHereShortcut function.

Disclosure:

I'm a developer of this module.

KUTlime
  • 131
  • 3
0

Follow this link. It's an awesome article to open the terminal in the exact folder like Linux. (Thank you @DarkDiamond) Here is the process:

  1. To add the Open command window here option to the context menu that displays when you right-click on a folder, press the Windows key + R to open the Run dialog box.
  2. type: regedit into the Open box and click OK.
  3. Navigate to this path: HKEY_CLASSES_ROOT\Directory\shell\cmd
  4. Take ownership of the cmd key and give yourself full control permission.
  5. Make sure the cmd key is selected. Then, right-click on the HideBasedOnVelocityId value on the right and select Rename.
  6. Change the name of the HideBasedOnVelocityId value to ShowBasedOnVelocityId and press Enter.
  7. Close the Registry Editor and restart the Windows Explorer process.
  8. Now you can Shift + right-click on a folder, not in it, and select Open command window here.
  • Welcome to SuperUser! Please do not post link only answers as the linked site might change, rendering your answer useless. Instead quote the most important part and provide the link for reference only. – DarkDiamond Aug 08 '22 at 07:50
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/1139360) – Toto Aug 08 '22 at 09:28
0

What worked for me on Windows 11 is checking "Use parent process directory" under "Starting directory" in terminal profile settings.

AdamTL
  • 1
  • 1
0

I just did this:

  1. Open windows terminal
  2. Click (+) and select configuration
  3. Go to Default Values in the side navigation bar
  4. Click on starting directory
  5. Set value to .
  6. Save settings
  7. Try to open from folder typing wt in navigation bar
Toto
  • 17,001
  • 56
  • 30
  • 41
Jesús
  • 1