Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wt support run command in application #4864

Closed
minhluan259 opened this issue Mar 10, 2020 · 19 comments
Closed

wt support run command in application #4864

minhluan259 opened this issue Mar 10, 2020 · 19 comments
Labels
Area-Commandline wt.exe's commandline arguments Issue-Question For questions or discussion Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal. Resolution-Answered Related to questions that have been answered

Comments

@minhluan259
Copy link

Description of the new feature/enhancement

How to start wt with bash like this:
C:\Windows\System32\cmd.exe /C start wt C:\test.sh value1

Proposed technical implementation details (optional)

test.sh
echo "Value: $1"

@minhluan259 minhluan259 added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Mar 10, 2020
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Mar 10, 2020
@zadjii-msft
Copy link
Member

I'm sorry, what are you asking for?

As of 0.9, Windows Terminal supports commandline arguments for a bunch of different scenarios. It should be as easy as running wt C:\test.sh value1

Are you trying to open a new tab in an existing WT window?

Are you trying to change the commandline of a profile so that it will run a script like test.sh (instead of powershell for example)?

Are you trying to use bash on WSL? On Cygwin? Git bash?

@zadjii-msft zadjii-msft added Issue-Question For questions or discussion Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Product-Terminal The new Windows Terminal. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Mar 10, 2020
@minhluan259
Copy link
Author

minhluan259 commented Mar 10, 2020

I'm using v0.9.

I'm trying to use bash on cmd, gitbash and cygwin
wt new-tab -p "cmd" C:\test.sh value1
wt new-tab -p "Git Bash" C:\test.sh value1
wt new-tab -p "Bash" C:\test.sh value1

All have the same issue
image
image
image

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Mar 10, 2020
@zadjii-msft
Copy link
Member

How would you normally run that script, from a cmd.exe window? Probably something like c:\path\to\bash.exe c:\test.sh value1 right? If that's the case, you'll need the following commandline:

wt c:\path\to\bash.exe c:\test.sh value1

What's happening when you run wt new-tab -p "Git Bash" C:\test.sh value1 is the Terminal is trying to run your "Git Bash" profile, but with a commandline of C:\test.sh value1 instead of what the usual commandline is for that profile.

@zadjii-msft zadjii-msft added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Area-Commandline wt.exe's commandline arguments and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels Mar 10, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Mar 10, 2020
@minhluan259
Copy link
Author

wt C:\cygwin64\bin\bash C:\test.sh value1
If I run on cmd, it opens the command window and auto close very quick
If I run on Cygwin64
it displays error
bash: /cygdrive/c/Users/minhl/AppData/Local/Microsoft/WindowsApps/wt: Permission denied

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Mar 10, 2020
@minhluan259
Copy link
Author

All I want is open Window Terminal with custom bash command via WinSCP
C:\Windows\System32\cmd.exe /C start wt new-tab -p "Bash" /cygdrive/c/Users/minhl/ssh.sh !U !@ !P
image

@zadjii-msft
Copy link
Member

wt C:\cygwin64\bin\bash C:\test.sh value1
If I run on cmd, it opens the command window and auto close very quick

That sounds like the script is terminating, and the terminal is closing in response to the last tab closing.

I'm not really sure how ssh.sh is supposed to work, but I'd guess that the following would work:

wt C:\cygwin64\bin\bash /cygdrive/c/Users/minhl/ssh.sh !U !@ !P

@minhluan259
Copy link
Author

Thank you.
The terminal is closing too. Is there any way to keep terminal open?

@zadjii-msft
Copy link
Member

You could try adding "closeOnExit": "never" to the profile you're launching. That's documented here:

Property Necessity Type Default Description
closeOnExit Optional String graceful Sets how the profile reacts to termination or failure to launch. Possible values: "graceful" (close when exit is typed or the process exits normally), "always" (always close) and "never" (never close). true and false are accepted as synonyms for "graceful" and "never" respectively.

@DHowett-MSFT DHowett-MSFT added Resolution-Answered Related to questions that have been answered Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels Mar 10, 2020
@ghost ghost added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Mar 24, 2020
@ghost
Copy link

ghost commented Mar 24, 2020

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 ghost closed this as completed Mar 27, 2020
@tihomir-kit
Copy link

tihomir-kit commented Jul 4, 2020

I'm having the same issue, I can't figure out how to run a command upon executing wt. For example, I would expect something as simple as wt dir to run WT and then execute the dir command. I just get this though: "[error 0x80070002 when launching `dir']".

#5528 seems relevant.

@ghost ghost removed the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Jul 4, 2020
@maicol07
Copy link

Same error

@zadjii-msft
Copy link
Member

dir is a "cmd intrinsic" - it's not an executable on its own, rather something built in to cmd itself. For things that are cmd intrinsics, you'll need to period the command with cmd /c , to make the command run inside the cmd.exe process. Ex cmd /c dir should work

@maicol07
Copy link

@zadjii-msft I've tried also to run the ls command but doesn't work

@zadjii-msft
Copy link
Member

Okay well what's the full commandline you're trying, and what's the path to ls on your machine?

@maicol07
Copy link

I mean I would like that when the terminal starts, it execute the ls command and shows his output.

So the final result would be:

@zadjii-msft
Copy link
Member

Alright, so, I can only guess that you're using WSL, and you're trying to run ls inside of WSL.

Turns out, this is in general, a hard problem with bash.

While this won't work in the general case, this will work for the simple ls case:

wt wsl bash -c "ls -lA --color & bash"

image

@maicol07
Copy link

@zadjii-msft There's only one issue with this: in my real use case, I need to get the output of a command that waits some seconds before outputting. With your solution, it returns control instantly after running the desired command

@zadjii-msft
Copy link
Member

Alright well, I'm sure there's other ways of doing this better. I'm not really a bash scripting expert. Maybe replacing the & with a \; (to escape the ;) might work better? I might just be really bad at bash.

The thread I linked on stack overflow has a long list of better ways of running a script than what I've posted. That's just the dead-simple ls case.

@Ones97
Copy link

Ones97 commented Apr 23, 2022

wt.exe --title "PuTTY" \plink.exe -pw !P -load "WinSCP temporary session" -no-antispoof

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Commandline wt.exe's commandline arguments Issue-Question For questions or discussion Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal. Resolution-Answered Related to questions that have been answered
Projects
None yet
Development

No branches or pull requests

6 participants