14

Is there a way to open a new tab in a running instance of Windows Terminal from CLI and make it point to a specific folder?

Every time I run wt.exe -d c:\my-folder it opens a new window.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Hemanshu Bhojak
  • 16,972
  • 16
  • 49
  • 64

5 Answers5

13

Now, we have this option in Windows Terminal's Settings.

enter image description here

Mai Hai
  • 976
  • 8
  • 12
  • This does not work from the CLI as the OP asks. See [the documentation](https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows): *This will always open a new window. Windows Terminal is not yet capable of opening new tabs or panes in an existing instance.* – c z May 24 '22 at 13:09
  • This now works from the CLI as the OP asks. – heksesang Jan 26 '23 at 09:05
11

If someone needs the commands to create a new tab (and not open a new window) from a context menu item: (if you are already in the directory):

wt -w 0 nt

(and if you click on the directory):

wt -w 0 nt -d %1

(to open in the current directory):

wt -w 0 nt -d %CD%

You can add these commands in the respective registry of each item (or in a new one)

Source: the GitHub discussion in the other answer.

if you run that in cmd or a script, it launches a new instance if none already running, or adds a tab if there is a running instance.

domechomsky
  • 313
  • 2
  • 9
1

This is an outstanding issue that is going to get fixed eventually: Add support for wt.exe to run commands in an existing Terminal Window #4472

howdoicode
  • 779
  • 8
  • 16
0

No, as per the documentation, calling wt.exe

...will always open a new window. Windows Terminal is not yet capable of opening new tabs or panes in an existing instance.

c z
  • 7,726
  • 3
  • 46
  • 59
-1

You can the tool neWin, a CLI command that opens new Window(s) or Tab(s) on WSL Windows Terminal (or KDE Konsole on native linux) and executes given bash command(s).

$ newin --workdir ~/myproject 'npm run start' 'npm run test:watch'

# executes each command in a separate new window and exit.

It runs on nodejs, works great on package.json scripts, but can also be used in any environment/platform.

(disclaimer: I'm the author of neWin)

Angelos Pikoulas
  • 1,002
  • 1
  • 14
  • 21