7

When I enter cmd or powershell into the Explorer address bar, the respective terminal will open a new window in the currently active path; can I do the same with Windows Terminal, as I want wt to act like powershell or cmd?

  • When entering wt, I get a new Windows Terminal, but in the default folder [my profile's home folder]
  • I could change a setting in settings.json [default profile is powerhell] by changing StartingDirectory from %USERPROFILE% to null, however that would then be active for all further Windows Terminal sessions (all sessions would be in %WinDir%\System32):
    {
      "commandline": "powershell.exe",
      "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
      "hidden": false,
      "name": "Windows PowerShell",
      "startingDirectory": "%USERPROFILE%"
    }
    
1
  • Powershell does not recognize % variables - use $env:UserProfile
    – JW0914
    Commented Mar 28, 2021 at 15:37

2 Answers 2

8

Solution

  • Rightclick on wt title bar
  • Go to settings
  • Check your default profile ("Windows PowerShell" by default)
  • Go to that profile on the left bar under Profiles
  • Click "Open JSON file"
  • in the JSON, under your profile in the "profiles", add the property "startingDirectory" : "."

"profiles": 
{
    "defaults": {},
    "list": 
    [
        {
            "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "hidden": false,
            "name": "Windows PowerShell",
            "startingDirectory" : "."
        },
        ...
1
  • With a recent version you can set the "Starting directory" of a profile directly from the settings window with the "Use parent process directory" checkbox
    – Ghidello
    Commented Dec 28, 2023 at 16:48
6

I only want "wt" act like "powershell" or "cmd".

Well, to be fair, that's not quite accurate. You want Windows Terminal to behave both ways. You still want it to start in your profile directory, unlike Windows Console (conhost.exe, which is the terminal that starts when by default for PowerShell and CMD). But sometimes you want it to start in the current directory instead.

Not that there's anything wrong with wanting it both ways, but you'll need to let Windows Terminal know which you want when you start it, of course.

To launch it from the command line to the current directory, run:

wt -d .

You can, of course, create an alias in PowerShell so that wt redirects to that command-line, but then you'd lose the flexibility of the other command-line arguments if you ever wanted to use them. So I'd recommend something like wtd for an alias name instead.

Note that you can also launch CMD (or another shell) instead of PowerShell (which is currently your default) this way with:

wt -d . cmd

or, if you were using WSL, you could launch the default distribution and shell (typical bash) with:

wt -d . wsl

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .