You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows Terminal多窗格执行指定命令的可行性及实现方法咨询

Can I Run Specific Commands in Multiple Windows Terminal Panes via a Shortcut?

Absolutely feasible! The issue with your current command boils down to how you're passing commands to each shell instance—Windows Terminal's wt tool needs you to account for how each shell (like Command Prompt) processes command-line inputs.

Let me break down the problem and fix this for you:

  • The core snag: When using -c with Command Prompt (cmd.exe), you can't just pass the raw command string directly. cmd.exe requires its own /c flag to execute a sequence of commands and handle them properly. Your current command skips this step, which is why it's not working as expected.

  • Corrected command: Here's the adjusted version that will launch both panes with their respective commands running:

    wt -p "Command Prompt" -d <your-project-path> -c "/c cls && php artisan serve" ; split-pane -p "Command Prompt" -H -d <your-project-path> -c "/c npm run watch"
    

    Just replace <your-project-path> with your actual working directory (e.g., C:\dev\my-laravel-app).

  • If you prefer PowerShell for the first pane: If you want to run the php artisan serve command in PowerShell instead of Command Prompt, note that cls is an alias for Clear-Host there. PowerShell accepts command strings directly via -c, so you'd use this version:

    wt -p "Windows PowerShell" -d <your-project-path> -c "Clear-Host && php artisan serve" ; split-pane -p "Command Prompt" -H -d <your-project-path> -c "/c npm run watch"
    
  • Quick extra tips:

    • If you want the panes to stay open after their commands finish (e.g., if php artisan serve stops and you want to keep the window to run other commands), swap /c with /k for Command Prompt, or add ; pause to the end of the PowerShell command.
    • Double-check that your profiles are named correctly (e.g., "Command Prompt" is the default name for the cmd profile—if you renamed it, use that exact name in the -p flag).

内容的提问来源于stack exchange,提问作者Mr.Singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 08:52:52