14

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?

0

1 Answer 1

29

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.

4
  • Thank you that is brillant! I don't know how you figured it out. I read the the windows doc and wt --help, and googled, and didnt get a clue at all. Jul 10, 2020 at 10:39
  • 4
    Add thanks to your link, for anyone looking for the power shell equivalent: Start-Process wt.exe -ArgumentList "PowerShell.exe", "-NoExit", "-Command", "dir" Jul 10, 2020 at 10:41
  • 3
    The new-tab param seems to open a new window for me.
    – ttugates
    Jan 19, 2021 at 14:40
  • Awesome, thank you! You can totally automate your routines with this one! Aug 24, 2021 at 7:35

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.