Closed minhluan259 closed 4 years ago
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?
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
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.
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
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
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
Thank you. The terminal is closing too. Is there any way to keep terminal open?
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. |
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.
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']".
Same error
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
@zadjii-msft I've tried also to run the ls command but doesn't work
Okay well what's the full commandline you're trying, and what's the path to ls
on your machine?
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:
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"
@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
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.
wt.exe --title "PuTTY"
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"