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

The ability to copy part of the output of the previous command to the current command #3670

Open
1 task done
pluma9 opened this issue May 3, 2023 · 1 comment
Open
1 task done
Labels
Area-Predictors Label for issues related to predictors Issue-Enhancement It's a feature request.

Comments

@pluma9
Copy link

pluma9 commented May 3, 2023

Prerequisites

  • Write a descriptive title.

Description of the new feature/enhancement

This is not a feature request that has a clear description and expectation, but more of a big general idea.

I often find myself need to grab a text from the output of the previous command and put it in the current command that is under compose. Using the mouse to select the text, copy and paste it into the current command does the job, but is inefficient.

Technically you can run the previous command and pipe it to a text editor and copy the text. However the point is that the need of copying part of the previous output is usually emergent, meaning you do not know that you need to do it until you are in the middle of composing the current command. As a workaround, you may perform some magic to always capture command output in a file and when needed, get the text from that file. However, with that, it is still requires additional steps and is not very neat.

There should be a way to:

  • Interactively select and copy (or some other mechanism that does not neccessarily require clipboard) a text from the previous output (right in the terminal?)
  • Or a command with text-selection syntax, e.g ssh $(2,3) (the third text from the second line of the previous output), which will resolve to the expected text when executed
  • Or open text editor with the content being the previous output, from which you can choose the text
  • etc.

A few examples that show how useful it is to be able to quickly grab some text from the previous output and put it in the current command:

> build
...
Error: syntax error in file 'foo/bar/baz.cpp'
> code foo/bar/baz.cpp
> health-check
...
Error: connection refused. IP: 208.232.96.166
> ping 208.232.96.166
> git status
modified: foo.txt
> git diff foo.txt
> Get-Content ./file.txt
One two three
four five six
> Set-ClipBoard -Value 'five'

Proposed technical implementation details (optional)

No response

@pluma9 pluma9 added the Issue-Enhancement It's a feature request. label May 3, 2023
@ghost ghost added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label May 3, 2023
@StevenBucher98
Copy link
Collaborator

Really cool ideas here, definitely find myself copying and pasting manually from previous commands to next ones. This may be a cool application to build a Feedback Provider around, which can tie into predictive intellisense of PowerShell, here is a blog post explaining what they are, https://devblogs.microsoft.com/powershell/what-are-feedback-providers/.

But in a nut shell if certain commands are ran like the examples you gave, the feedback provider could trigger to suggest running the next commands (i.e code <X> etc) and that would be predicted to the user next so all the user has to do is tap the right arrow key to accept the suggestion and reducing the need to copy and paste and even type out the whole command!

So it would look something like this:

PS>build
...
Error: syntax error in file 'foo/bar/baz.cpp'

[EditingFeedbackProvider]
  Looks like you ran into an error in that file, you can edit it by running:
    ➤ code foo/bar/baz.cpp 
PS>code foo/bar/baz.cpp # this is predicted and not typed out by the user yet

Even better we can just have the feedback provider not return a feedback item and have it pass the actions to the predictive intellisense so its just:

PS>build
...
Error: syntax error in file 'foo/bar/baz.cpp'
PS>code foo/bar/baz.cpp # this is predicted and not typed out by the user yet

cc @daxian-dbw cause you may find this interesting

@StevenBucher98 StevenBucher98 added Area-Predictors Label for issues related to predictors and removed Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. labels Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Predictors Label for issues related to predictors Issue-Enhancement It's a feature request.
Projects
None yet
Development

No branches or pull requests

2 participants