Feature Request: multi-commanding #3737

Closed
opened 2026-01-30 23:28:50 +00:00 by claunia · 5 comments
Owner

Originally created by @AshrafMichail on GitHub (Sep 3, 2019).

Description of the new feature/enhancement

Problem
The following pattern is inefficient from the command-line and often requires an alternate GUI tool:

  1. Run a command that produces a list
  2. For each entry in the list, run another command

For example:

  1. git status (say we are interested in the conflict list)
  2. For each file in the list above, "vi filename" to resolve merge conflicts
  3. For each file in the list above, "git add"

In practice, this pattern has so much duplicate typing from the command-line, often people are required to use a GUI tool instead.

Proposal
Add a multi-command feature so the list work flow becomes:

  1. Run a command that produces the list (eg. git status)
  2. Alt-select list of interesting files
  3. Type "git add {special key}" to enter multi-command mode which replicates the current typed line for each row in the selection.
  4. Either type more commands afterwards or hit {enter} after to run multiple commands one at a time in the order they appear in the row selection.
Originally created by @AshrafMichail on GitHub (Sep 3, 2019). # Description of the new feature/enhancement **Problem** The following pattern is inefficient from the command-line and often requires an alternate GUI tool: 1. Run a command that produces a list 2. For each entry in the list, run another command For example: 1. git status (say we are interested in the conflict list) 2. For each file in the list above, "vi filename" to resolve merge conflicts 3. For each file in the list above, "git add" In practice, this pattern has so much duplicate typing from the command-line, often people are required to use a GUI tool instead. **Proposal** Add a multi-command feature so the list work flow becomes: 1. Run a command that produces the list (eg. git status) 2. Alt-select list of interesting files 3. Type "git add {special key}" to enter multi-command mode which replicates the current typed line for each row in the selection. 4. Either type more commands afterwards or hit {enter} after to run multiple commands one at a time in the order they appear in the row selection.
Author
Owner

@zadjii-msft commented on GitHub (Sep 3, 2019):

Sounds to me like what you're looking for is the xargs linux tool. A sample using wsl to achieve your above use case:

image

@zadjii-msft commented on GitHub (Sep 3, 2019): Sounds to me like what you're looking for is the [`xargs`](http://man7.org/linux/man-pages/man1/xargs.1.html) linux tool. A sample using wsl to achieve your above use case: ![image](https://user-images.githubusercontent.com/18356694/64204930-65b22e80-ce5c-11e9-8d1e-51c0f49ca1e1.png)
Author
Owner

@AshrafMichail commented on GitHub (Sep 3, 2019):

xargs is close but has problems:

  1. You need to use something like sed which is slower than alt-selection .
  2. It executes commands without you knowing what it will execute ahead of time. It's the same fundamental problem of "!" where it goes executes something and you hope it's what you expected. You can turn on prompting, but that slows down the flow.

The proposal is more like the multicursor feature in editors. For the above example, one multicommanding typing option would be:

git status
git add {ctrl-alt-select filelist} <enter>

Here I added ctrl-alt-select as a way to specify multi-command mode, but you could also do a keybinding although there's risk of conflict with key bindings.

@AshrafMichail commented on GitHub (Sep 3, 2019): xargs is close but has problems: 1. You need to use something like sed which is slower than alt-selection . 2. It executes commands without you knowing what it will execute ahead of time. It's the same fundamental problem of "!" where it goes executes something and you hope it's what you expected. You can turn on prompting, but that slows down the flow. The proposal is more like the multicursor feature in editors. For the above example, one multicommanding typing option would be: > git status > git add {ctrl-alt-select filelist} \<enter\> Here I added ctrl-alt-select as a way to specify multi-command mode, but you could also do a keybinding although there's risk of conflict with key bindings.
Author
Owner

@zadjii-msft commented on GitHub (Sep 5, 2019):

Honestly with sounds like a shell feature to me, not a terminal feature. The terminal would need to know some pretty intimate details about the shell that's running for this to work in a general sense. How would this functionality work in something like vim or emacs? What about tmux, or even ssh?

That being said, with the tight coupling to the act of selecting, something wholly owned by the terminal, it doesn't seem like a purely shell feature only. You'd almost need a dedicated terminal+shell application, like the Powershell ISE.

Maybe I'm wrong on this, and someone can clarify how this could be done in a generic way.

@zadjii-msft commented on GitHub (Sep 5, 2019): Honestly with sounds like a _shell_ feature to me, not a _terminal_ feature. The terminal would need to know some pretty intimate details about the shell that's running for this to work in a general sense. How would this functionality work in something like `vim` or `emacs`? What about `tmux`, or even `ssh`? That being said, with the tight coupling to the act of _selecting_, something wholly owned by the terminal, it doesn't seem like a purely _shell_ feature only. You'd almost need a dedicated terminal+shell application, like the Powershell ISE. Maybe I'm wrong on this, and someone can clarify how this could be done in a generic way.
Author
Owner

@AshrafMichail commented on GitHub (Sep 5, 2019):

@zadjii-msft, I think you are right that it's a shell feature and not a terminal feature. I think your xargs suggestion was close as well.

I think I can accomplish this in powershell for example by writing an xargs like command that reads clipboard, likely needs to convert forward slashes to backslashes, and just replays commands. So, flow would become:

git status
{alt-select filelist}
ClipArgs git add

For Linux, you can kind of do this with xargs + xclip, although, xclip doesn't seem to work with WSL.

For emacs, this essentially becomes a way to replace a selection with an prefix/postfix version of the selection which isn't necessary. vi has risk of interacting badly with vi modes and also doesn't need the prefix/postfix feature.

@AshrafMichail commented on GitHub (Sep 5, 2019): @zadjii-msft, I think you are right that it's a shell feature and not a terminal feature. I think your xargs suggestion was close as well. I think I can accomplish this in powershell for example by writing an xargs like command that reads clipboard, likely needs to convert forward slashes to backslashes, and just replays commands. So, flow would become: > git status > {alt-select filelist} <enter> > ClipArgs git add For Linux, you can kind of do this with xargs + xclip, although, xclip doesn't seem to work with WSL. For emacs, this essentially becomes a way to replace a selection with an prefix/postfix version of the selection which isn't necessary. vi has risk of interacting badly with vi modes and also doesn't need the prefix/postfix feature.
Author
Owner

@bitcrazed commented on GitHub (Sep 9, 2019):

@AshrafMichail Good to hear. Closing this issue as you have a work-around.

@bitcrazed commented on GitHub (Sep 9, 2019): @AshrafMichail Good to hear. Closing this issue as you have a work-around.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#3737