Execute a code, or a binary as an input for SendInput command #18941

Closed
opened 2026-01-31 06:29:02 +00:00 by claunia · 4 comments
Owner

Originally created by @Hixon10 on GitHub (Nov 23, 2022).

Description of the new feature/enhancement

I propose to extend sendInput command (https://github.com/microsoft/terminal/issues/3799) . At present, it allows to pass String input, which should be displayed on the terminal. I want to execute a code and display the result, instead of static text.

For example, I want to insert a current git branch to the current terminal cursor position. I can get the name with help git rev-parse --abbrev-ref HEAD. So, I would like to have the following hotkey in the terminal:

{
  "command": {
    "action": "sendInput",
    "input": $(git rev-parse --abbrev-ref HEAD), or ./get-branch-name.exe
  },
  "keys": "ctrl+k"
}

At present, I cannot do it, because input accepts only strings. There are a few workarounds, like, "input": "git rev-parse --abbrev-ref HEAD| Set-Clipboard\r, but they don't allow to insert needed input in place.

Originally created by @Hixon10 on GitHub (Nov 23, 2022). # Description of the new feature/enhancement I propose to extend [sendInput](https://learn.microsoft.com/en-us/windows/terminal/customize-settings/actions#send-input) command (https://github.com/microsoft/terminal/issues/3799) . At present, it allows to pass `String` input, which should be displayed on the terminal. I want to execute a code and display the result, instead of static text. For example, I want to insert a current `git` branch to the current terminal cursor position. I can get the name with help `git rev-parse --abbrev-ref HEAD`. So, I would like to have the following hotkey in the terminal: ``` { "command": { "action": "sendInput", "input": $(git rev-parse --abbrev-ref HEAD), or ./get-branch-name.exe }, "keys": "ctrl+k" } ``` At present, I cannot do it, because `input` accepts only strings. There are a few workarounds, like, `"input": "git rev-parse --abbrev-ref HEAD| Set-Clipboard\r`, but they don't allow to insert needed input in place.
claunia added the Issue-FeatureResolution-Duplicate labels 2026-01-31 06:29:02 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Nov 30, 2022):

I love this. I've sorta made similar notes in #12927 in the past, but this does seem... simpler? At least, this seems to make syntactic sense.

Not sure how this would work with #12861

@zadjii-msft commented on GitHub (Nov 30, 2022): I love this. I've sorta made similar notes in #12927 in the past, but this does seem... simpler? At least, this seems to make syntactic sense. Not sure how this would work with #12861
Author
Owner

@zadjii-msft commented on GitHub (Nov 30, 2022):

Though, admittedly, this is also probably never gonna work.

  • What would the execution model look like?
  • We almost never know the CWD that a shell is running in, so we're more than likely not going to be able to run this in the directory you wanted.

I'm gonna merge this into /dup #12927. Fun suggestion, but technically very challenging 😄

@zadjii-msft commented on GitHub (Nov 30, 2022): Though, admittedly, this is also probably never gonna work. * What would the execution model look like? * We almost never know the CWD that a shell is running in, so we're more than likely not going to be able to run this in the directory you wanted. I'm gonna merge this into /dup #12927. Fun suggestion, but technically very challenging 😄
Author
Owner

@ghost commented on GitHub (Nov 30, 2022):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Nov 30, 2022): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@Hixon10 commented on GitHub (Nov 30, 2022):

https://github.com/microsoft/terminal/issues/12927 is kinda similar, yes.

Thank you for the answer.

@Hixon10 commented on GitHub (Nov 30, 2022): https://github.com/microsoft/terminal/issues/12927 is kinda similar, yes. Thank you for the answer.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18941