Unable to set Command while running a cmd script #16829

Closed
opened 2026-01-31 05:24:17 +00:00 by claunia · 6 comments
Owner

Originally created by @jiveshwar on GitHub (Feb 20, 2022).

I want to open 1 of the windows with ssh login automatically, and hence I wrote a file abc.cmd with the following content, but it is giving errors:

wt.exe -p Bash -d "c:/test/folder1"; -p Bash -c "ssh test@192.168.0.10"; -p Bash -d "C:/Projects/test"; focus-tab -t 0

image

Also tried:
wt.exe -p Bash -d "c:/test/folder1"; -p Bash /c "ssh test@192.168.0.10"; -p Bash -d "C:/Projects/test"; focus-tab -t 0

but again got the similar error:
image

Is there any way I can set the commands as mentioned here:
image

Originally created by @jiveshwar on GitHub (Feb 20, 2022). I want to open 1 of the windows with ssh login automatically, and hence I wrote a file abc.cmd with the following content, but it is giving errors: `wt.exe -p Bash -d "c:/test/folder1"; -p Bash -c "ssh test@192.168.0.10"; -p Bash -d "C:/Projects/test"; focus-tab -t 0` ![image](https://user-images.githubusercontent.com/7592502/154863809-495ed993-9e2c-48d3-8965-afc46f3f6f63.png) Also tried: `wt.exe -p Bash -d "c:/test/folder1"; -p Bash /c "ssh test@192.168.0.10"; -p Bash -d "C:/Projects/test"; focus-tab -t 0` but again got the similar error: ![image](https://user-images.githubusercontent.com/7592502/154863856-6577f059-86e7-440b-8926-c36d74bcc65c.png) Is there any way I can set the commands as mentioned here: ![image](https://user-images.githubusercontent.com/7592502/154863942-f63dda5c-c552-4f5e-8837-4d37414262ef.png)
Author
Owner

@zadjii-msft commented on GitHub (Feb 22, 2022):

When you pass a commandline to a new-tab subcommand, it doesn't append that commandline to the profile's commandline, it replaces it. So when you do

new-tab -p Bash -c "ssh test@192.168.0.10"

You're telling wt:

  • open a new tab
  • use the "Bash" profile

But then our arg parser gets confused on the -c, because wt new-tab doesn't accept a -c arg itself.

The way you probably want do to this is

new-tab -p Bash -- {whatever the bash commandline is} -c ssh test@192.168.0.10

the -- will escape the remainder of the args to this new-tab command and treat the rest of the string as the new commandline.

Does that make sense?

@zadjii-msft commented on GitHub (Feb 22, 2022): When you pass a `commandline` to a `new-tab` subcommand, it doesn't _append_ that `commandline` to the profile's` commandline`, it _replaces_ it. So when you do ``` new-tab -p Bash -c "ssh test@192.168.0.10" ``` You're telling `wt`: * open a new tab * use the "Bash" profile But then our arg parser gets confused on the `-c`, because `wt new-tab` doesn't accept a `-c` arg itself. The way you probably want do to this is ``` new-tab -p Bash -- {whatever the bash commandline is} -c ssh test@192.168.0.10 ``` the `--` will escape the remainder of the args to this `new-tab` command and treat the rest of the string as the new `commandline`. Does that make sense?
Author
Owner

@jiveshwar commented on GitHub (Feb 22, 2022):

I think the syntax is something else. This is not working
wt.exe -p Bash -- -c ssh test@192.168.0.10
AND
wt.exe -p Bash -- ssh test@192.168.0.10
AND
wt.exe new-tab -p Bash -- -c ssh test@192.168.0.10
AND
wt.exe new-tab -p Bash -- ssh test@192.168.0.10

all are giving errors like:
image

@jiveshwar commented on GitHub (Feb 22, 2022): I think the syntax is something else. This is not working `wt.exe -p Bash -- -c ssh test@192.168.0.10` AND `wt.exe -p Bash -- ssh test@192.168.0.10` AND `wt.exe new-tab -p Bash -- -c ssh test@192.168.0.10` AND `wt.exe new-tab -p Bash -- ssh test@192.168.0.10` all are giving errors like: ![image](https://user-images.githubusercontent.com/7592502/155170919-47143687-0ca2-4241-89f8-a62d3f34c57b.png)
Author
Owner

@zadjii-msft commented on GitHub (Feb 22, 2022):

That's exactly what I'd expect to happen there. You need to make sure to add the Bash profile's commandline to the start. What's the commandline of your Bash profile? Something like c:\path\to\bash.exe --some -args? Then your command would need to be

new-tab -p Bash -- c:\path\to\bash.exe --some -args -c ssh test@192.168.0.10
@zadjii-msft commented on GitHub (Feb 22, 2022): That's exactly what I'd expect to happen there. You need to make sure to add the Bash profile's `commandline` to the start. What's the commandline of your Bash profile? Something like `c:\path\to\bash.exe --some -args`? Then your command would need to be ``` new-tab -p Bash -- c:\path\to\bash.exe --some -args -c ssh test@192.168.0.10 ```
Author
Owner

@237dmitry commented on GitHub (Feb 23, 2022):

Why explicitly use the --profile parameter if the profile picks up the command anyway? For example I set micro in profiles, when I launch this editor from script the terminal opens this editor according to its profile settings (font, cursor, tab color):

param (
    [Parameter(Mandatory)]
    [string] $file
)

$Env:MICRO_TRUECOLOR = 1

$file = Get-Item $file
wt --window 0 new-tab --startingDirectory $file.Directory micro $file.Name
@237dmitry commented on GitHub (Feb 23, 2022): Why explicitly use the `--profile` parameter if the profile picks up the command anyway? For example I set `micro` in profiles, when I launch this editor from script the terminal opens this editor according to its profile settings (font, cursor, tab color): ```powershell param ( [Parameter(Mandatory)] [string] $file ) $Env:MICRO_TRUECOLOR = 1 $file = Get-Item $file wt --window 0 new-tab --startingDirectory $file.Directory micro $file.Name ```
Author
Owner

@zadjii-msft commented on GitHub (Feb 23, 2022):

A Profile is a lot more than just a commandline, perhaps OP want's to make sure to use the colorscheme, font, etc. from their "Bash" profile rather than their default settings.

@zadjii-msft commented on GitHub (Feb 23, 2022): A Profile is a lot more than just a commandline, perhaps OP want's to make sure to use the colorscheme, font, etc. from their "Bash" profile rather than their default settings.
Author
Owner

@ghost commented on GitHub (Feb 27, 2022):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Feb 27, 2022): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16829