30

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.

0

7 Answers 7

23

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

10
  • 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, 2019 at 9:31
  • What exactly does not work? Is the issue with terminal not starting at all, or with the directory being different then expected? Sep 22, 2019 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, 2019 at 14:15
  • 3
    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. Nov 27, 2019 at 12:49
  • 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, 2022 at 5:32
52

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

3
  • 2
    This should be the accepted answer. Maybe terminal has changed since that one was chosen.
    – SixOThree
    Apr 15, 2020 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? Jul 12, 2020 at 8: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: 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, 2020 at 23:03
48

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.

3
  • 2
    This should be the accepted answer! Oct 15, 2020 at 8:49
  • how do you know the answer?
    – Ooker
    Oct 6, 2021 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, 2022 at 12:46
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.

0

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

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.
2
  • 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. Aug 8, 2022 at 7: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
    – Toto
    Aug 8, 2022 at 9:28
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.