insect icon indicating copy to clipboard operation
insect copied to clipboard

Feature to share multi-line history

Open ErikDeBruijn opened this issue 2 years ago • 7 comments

Currently, insect.sh remembers the last command on the query part of the URL.

When sharing the link, this means that multiple lines that depend on each other, can't be shared in this way.

image

I was thinking of the following enhancement: If there's support for a %0A or some other line termination character and the instructions could be executed one by one after splitting on that character.

Note: @sharkdp I just became sponsor as a thank you! You can judge whether this feature request is a priority to you or not. Just know that I'd love to see this added. ;)

ErikDeBruijn avatar Mar 17 '22 12:03 ErikDeBruijn

Thank you for your feature request.

I agree that this would be nice. However, where would it stop? If someone has a 20 line history, should all commands be appended in the URL?

This is very much related to https://github.com/sharkdp/insect/issues/145.

Note: @sharkdp I just became sponsor as a thank you!

Thank you very much!

sharkdp avatar Mar 18 '22 20:03 sharkdp

I realize this would add UI complexity, but would a "share" button (or similar), with a field to choose how many lines of history are included, not be the best solution here?

Qyriad avatar Mar 24 '22 08:03 Qyriad

The maximum length of a query is already capped (saw something like a 2k character limit in a path). Why not allow anything within the RFC constraint?

ErikDeBruijn avatar Apr 06 '22 11:04 ErikDeBruijn

In case it exceeds the RFC limit it could simply not offer the share option or give a warning when attempting a share. But in most cases a multi-line calculation is within the limit.

ErikDeBruijn avatar Jul 10 '22 14:07 ErikDeBruijn

Ok, I'd be okay with adding a "share" button below the terminal. Or a new share terminal command.

Splitting the input into multiple lines and executing each of them in succession is probably not a huge deal. But someone would have to add the necessary HTML+JavaScript to support this.

sharkdp avatar Jul 11 '22 20:07 sharkdp

I personally wouldn't know where to start. 😳 Hopefully there is somebody who is familiar with the code who's interested in the feature.

ErikDeBruijn avatar Jul 13 '22 06:07 ErikDeBruijn

The place to start would be here:

https://github.com/sharkdp/insect/blob/1bce3a9c8f835de9eb00c074306893aaf520748c/web/index.html#L132-L138

Instead of calling term.exec(…) on the full query string (queryParams.get("q")), the input would need to be split into several lines, and then passed to term.exec(…) in a loop.

sharkdp avatar Jul 13 '22 06:07 sharkdp

If someone thinks this is still valuable, please file a new ticket in the follow-up project: https://github.com/sharkdp/numbat

Numbat already supports multi-line inputs and multi-line pasting (#145), so implementing this in Numbat is likely easier.

sharkdp avatar Sep 26 '23 20:09 sharkdp