warpdotdev / Warp

Warp is a modern, Rust-based terminal with AI built in so you and your team can build great software, faster.
https://warp.dev
Other
20.25k stars 337 forks source link

Intelligent Copy All (Prompt, Command, Output) is needed, which prefaces command #2800

Open imgrant opened 1 year ago

imgrant commented 1 year ago

Discord username (optional)

No response

Describe the solution you'd like?

I'd like to be able to copy the command and output (aka Copy Both) from a block, and paste it into e.g. Slack, so that it is clear it is a shell command and resulting output ā€” the normal convention for this is to preface the command with a prompt marker, $, e.g.:

$ echo hello
hello

Important feature because I basically do it all the time.

Is your feature request related to a problem? Please describe.

Currently, if you use Copy Both, you get the command output, but without any prompt marker, e.g.:

echo hello
hello

It's not 100% clear/doesn't follow convention, that echo hello was entered at the shell prompt, and hello is the output.

Additional context

There are two workarounds:

  1. Copy Both, paste into e.g. Slack, manually add $ to the front of the command Pros: not that hard Cons: manual effort

  2. Copy Prompt, paste, Copy Both, paste Pros: includes original prompt Cons: default prompt in Warp is a two-liner, many people have complex prompts, desired convention for showing examples is just a simple $

As a bonus, it would be super-ideal if Warp could preface the command with $ for a normal user, and # for root. This is also a widely-used convention on the web.

Addendum for clarity: Copy Command alone should still not preface with $ or #, because a) that is convention, b) if you're just copying the command it's often to paste and run, verbatim.

How important is this feature to you?

4

Warp Internal (ignore) - linear-label:770f6576-d6c0-4e4f-a259-fc64b5156087

None

andrewtaehoon commented 1 year ago

Same concern when copying both command and output. It's impossible to discern which is the command and the output when copying and pasting multiple terminal block of commands and outputs.

tophee commented 11 months ago

Indeed, this would be very nice to have. Feels weird when I'm using this super-smart terminal but when I copy and paste command and output (which I do all the time), I have to make some dumb manual adjustments...

@imgrant when you said

As a bonus, it would be super-ideal if Warp could preface the command with $ for a normal user, and # for root. This is also a widely-used convention on the web.

I finally understood why people sometimes use $ and sometimes # :-) Thanks for clarifying.

But one question: Are there any conventions for dealing with situations where the output happens to start with # (or $) as in

getfacl /mnt/mypool/
# file: /mnt/mypool/
# owner: root
# group: wheel
user::rwx
group::r-x
other::r-x

The above is copied and pasted straight from a warp session. If this feature requested were implemented, it would be

# getfacl /mnt/mypool/
# file: /mnt/mypool/
# owner: root
# group: wheel
user::rwx
group::r-x
other::r-x

which, in this case, is neither better nor worse. In both versions, you need contextual knowledge to infer what is the prompt and what's the output. In fact, one might argue that the second version is more prone to misreadings as it could be read as a series of four commands of which only the last one yielded an output.

warpdotdev-devx[bot] commented 11 months ago

Thanks for this feature request! This can certainly be improved. If/When this is being worked on, we'll updated this thread.

To anyone else interested in this feature, please add a šŸ‘ to the original post at the top to signal that you want this feature, and subscribe if you'd like to be notified.

zachbai commented 11 months ago

Not sure if this is satisfactory for your specific use case, but if you're indeed copying content to share in Slack, the block sharing feature might be useful to you.

image

Here's the link that was created: https://app.warp.dev/block/9KMSKvGHv0AxXIV1t3qQK2

Regarding the specific copy/paste behavior, maybe we could have some additional option for preserving some structural distinction between command/output, but I think due to the corner cases mentioned by @tophee we probably wouldn't make this the default.

imgrant commented 11 months ago

Well, the corner case is a really small corner. Personally I think it is acceptable, but regardless it is easily mitigated by one of:

Don't let this wrinkle distract from the main thrust of the request, which is a single copy item that includes prompt, command & output.

tophee commented 11 months ago

Don't let this wrinkle distract from the main thrust of the request, which is a single copy item that includes prompt, command & output.

@zachbai I totally agree with @imgrant above. I didn't mean to call the request into question but support it. I just took the opportunity to ask what is/would be good practice in certain (very rare) edge cases, as this may further inform the algorithm for this feature.

always use $ for the prompt and never #

Do you mean because $ is least likely to come up a the beginning of an output?

copy the actual prompt from Warp (and leave it up to the user to edit if desired)

I think if that rule were applied only to those edge cases it would be more confusing to the user, as it would not be immediately apparent to the user why the # or $ is suddenly omitted.

If there is no common practice for this (I'm not in the industry, so I don't know), then I think the best way to deal with these edge cases is to ignore them and apply the # or $ in the same fashion regardless of the output.

Whether # and $ should be applied based on root vs non-root or whether one of them should be applied all the time could be a user setting.

the block sharing feature might be useful to you.

Thanks for pointing that out. But the rendering of the output behind the sharing link is plagued by the exact same problem that this feature request is trying to address.

maybe we could have some additional option for preserving some structural distinction between command/output

yes, please do. Applying a regex to the copied text should be very quick and easy to implement, right?