12

I can start Windows Terminal with wt. I have read the Windows Terminal documentation on command-line arguments, and it just covers passing an argument for setting up terminal panes, not passing in actual executable commands.

For example, a minimal reproducible example: Requires Windows Terminal installed:

Open a CMD prompt in Windows and type:

dir | wt

This starts Windows Terminal, but it does not receive the dir command. How does one pass the executable command to Windows Terminal?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
run_the_race
  • 1,344
  • 2
  • 36
  • 62

1 Answers1

27

Use

wt new-tab -p "Command Prompt" -d "%cd%" cmd /k dir
  • You can omit new-tab (it’s a default command).

  • Omitting -d "%cd%" seems to be equivalent to -d "%USERPROFILE%".

  • You can omit -p "Command Prompt" if your default profile is set to the cmd.exe profile. Check the wt settings in the following file (Windows):

    %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
    

Try a more complex command than dir, for instance

wt new-tab -p "Command Prompt" -d "%cd%" cmd /k "dir & type "%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json""

Please check the How to pass commands into the shell opened in new Windows Terminal question as well.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
JosefZ
  • 28,460
  • 5
  • 44
  • 83