Skip to content

Add support for send-input subcommand #9368

Closed as not planned
Closed as not planned

Description

you can execute when creating tab

exp:
wt.exe -w 2 sp -V wsl.exe zsh -ic "l\; /bin/zsh"

but there is not way to execute when it's already created or i do sth wrong?

Environment

21322.1000
Windows 10 Feature Experience Pack 321.2906.0.3
wsl2
Linux DESKTOP-RRHRJSC 4.19.128-microsoft-standard #1 .... x86_64 x86_64 x86_64 GNU/Linux
Windows Terminal Preview 1.7.572.0

Steps to reproduce

wsl
wt.exe -w 2 focus-tab -t 3 /bin/bash -c 'ls'

Expected behavior

executes /bin/bash -c 'ls' in focused tab

or

introduce -exec flag that executes passed string

wt.exe -w 2 focus-tab -t 3 -exec "/bin/bash -c 'ls'"

Actual behavior

only focuses tab

Activity

  1. ghost added
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Mar 3, 2021
  2. ghost added
    Needs-Tag-FixDoesn't match tag requirements
    on Mar 3, 2021
  3. zadjii-msft commented on Mar 3, 2021

    @zadjii-msft
    Member

    So, if I'm reading this correctly, what you're really looking for is the sendInput action, but as a subcommand on the commandline? So that when you already have an existing terminal instance, you could do

    wt -w send-input ls
    

    to send "ls" to the active pane. That makes sense to me. It's something we've been back and forth on in the past - I've been a little hesitant to allow other processes to "inject" input into terminal instances like this. That being said, we're not really pursuing mixed elevation anymore, so now I'm less worried about this.

    What I am worried about is how we encode special characters. Not all shells support multi-line input, so putting a raw \n into the input might be tricky. It's easier to encode in json where you can just literally say "ls\n". A flag to say "please follow this input string with a \n" isn't a terrible idea, but then what if you want multiple commands? What if you want an arrow key? So we'd need to have a good way of encoding escape character in the input (regardless of shell).

  4. ghost removed
    Needs-Tag-FixDoesn't match tag requirements
    on Mar 3, 2021
  5. changed the title [-]windows terminal preview - can NOT execute command after tab focus[/-] [+]Add support for `send-input` subcommand[/+] on Mar 3, 2021
  6. ngmariusz commented on Mar 4, 2021

    @ngmariusz
    Author

    Yes, thank you "send-input" is much better name;

    As i understand encoding/escaping is well know problem

    no long ago i was trying this ${selectedText} in vscode tasks ( https://code.visualstudio.com/docs/editor/variables-reference )
    and it bited me couple of times but eventually i figured that out, we are developers after all ;)

    ...so perhaps accepting "multiline / etc input" in a smart way is yet another feature? and we could try how idea is working out in a wild.

    to add more context of my use case

    i'd like to have one monitor of multiple opened terminals only and pushing to chosen one with my ide shortcuts from another monitor

    until remote control was released my scenario was

    1. create command in editor (as i usually have there more context than terminal history) 
    2. select 
    3. copy 
    4. change to desired terminal window (mostly with alt+tab 1-n times until got wanted one )
    5. select desired tab
    6. Paste
    7. Go  back (mostly with alt+tab 1-n times until got wanted one)
    

    with remote control currently i have

    1. create command in editor (as i usually have there more context than terminal history) 
    2. select 
    3. copy 
    4. with single shortcut -> select desired tab with know window id and tab index             
    5. -
    6. Paste
    7. Go back (mostly with alt+tab 1-n times until got wanted one)
    

    it's better but i need

    1. create command in editor (as i usually have there more context than terminal history) 
    2. select 
    3. with single shortcut -> select desired tab with know window id and tab index and execute my selected string there        
    4. -               
    5. -
    6. -
    7. -  
    

    there are also scenarios when command is derived entirely from context so if you'd create shortcut for this in your IDE you could

    1. -
    2. -
    3. with single shortcut -> select desired tab with know window id and tab index and execute command is derived entirely from context there        
    4. -               
    5. -
    6. -
    7. -
    

    i hope it's worth pursuing

    also

    it helps alot with work ergonomic ( and wrist pain ;) )

  7. removed
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Mar 13, 2021
  8. joswr1ght commented on Feb 14, 2022

    @joswr1ght

    I'm not terribly concerned about multiline input, since you can stack multiple send-input commands to achieve the same goal. Perhaps it is a little less graceful, but it would allow for behavior similar to the current split-pane [commandline] syntax where \n is implied. The caller has to consider the requirements for whether the profile accepts any special characters sent.

    I don't really see a use case for sending arrow keys as input (famous last words perhaps). My thinking is that this extends the precedent for functionality set by split-pane [commandline] for a lot of added flexibility.

  9. 3N4N commented on Jul 18, 2023

    @3N4N

    This feature would be similar to tmux's send-keys action. It could be used in several ways, but I use it to send text from Vim to a REPL, basically setting up an ad-hoc IDE. (Yes Vim has embedded terminal now, but it cannot really replace a fully-functioning terminal.)

    Wezterm also has a similar feature. It's called send-text.

  10. noheromen commented on Oct 12, 2023

    @noheromen

    Any progress on this feature? I would like to have it too. Thanks

  11. zadjii-msft commented on Oct 12, 2023

    @zadjii-msft
    Member

    Nope. We'll make sure to update this thread when there is. In the meantime, might I recommend the Subscribe button?
    image
    That way you'll be notified of any updates to this thread, without needlessly pinging everyone on this thread ☺️


    I'm also still not sure how confident I feel about the ability for arbitrary exes to send arbitrary keystrokes to random shells. Maybe I'd feel more confident if it was an opt-in thing. Like, you need to turn on a special setting first to say "yep, I'm gonna do some scripting now" - though, if it was just in the settings.json, there's literally nothing that prevents malicious.exe from just changing the settings file itself.

  12. einarpersson commented on Jan 24, 2024

    @einarpersson

    I have really enjoyed working with WSL2 as a combination of Windows and Linux, but not being able to programmatically control the terminal app itself (including sending arbitrary input to it) feels limiting right now in a time of automation.

  13. laffo16 commented on Apr 12, 2026

    @laffo16

    I implemented this locally on top of current main and opened a draft PR from my fork: #20106.

    The patch adds:

    • wt send-input <input...>
    • --enter
    • --enter-delay-ms <ms>
    • --activate

    It supports existing-window automation flows like:

    • wt -w 0 send-input "hello"
    • wt -w 0 focus-tab -t 1 ; send-input --enter "echo TAB2_OK"

    For existing-window send-input, background delivery is the default; --activate opts back into the normal summon behavior.

    I also kept structural chains like new-tab ; send-input and split-pane ; send-input on the existing activation path.

  14. DHowett commented on Apr 13, 2026

    @DHowett
    Member

    to send "ls" to the active pane. That makes sense to me. It's something we've been back and forth on in the past - I've been a little hesitant to allow other processes to "inject" input into terminal instances like this. That being said, we're not really pursuing mixed elevation anymore, so now I'm less worried about this.

    Since this message was written, we actually did pursue mixed elevation. I have not stopped worrying about the security risk this opens up, and so I am going to move this to the rejected state. Sorry, and thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Commandlinewt.exe's commandline argumentsIssue-TaskIt's a feature request, but it doesn't really need a major design.Needs-Tag-FixDoesn't match tag requirementsProduct-TerminalThe new Windows Terminal.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions