gum icon indicating copy to clipboard operation
gum copied to clipboard

Possible to not remove prompt/response?

Open dmd opened this issue 6 months ago • 1 comments

Suppose I do:

FRUIT=$(gum input --header="Your favorite fruit")

Once I type in a response and hit return, the header, prompt, and response all disappear. I then need to write something back to the user to show that the interaction actually happened and I got the response.

I'd like a flag to leave all of that on the screen, rather than removing it, after the interaction.

dmd avatar Dec 19 '23 16:12 dmd

Wanting the same behavior for choose and filter, I looked at the code (not being a Go programmer) to see if I could find anything that looked like deinit() or init(), since the less man page calls this option --no-init:

-X or --no-init
     Disables sending the termcap initialization and deinitialization
     strings to the terminal.  This is sometimes desirable if the
     deinitialization string does something unnecessary, like clearing
     the screen.

Didn't have any luck with that, just upon a cursory review. I think that's buried in one of the other charmbracelet libraries, if not some other even-more-low-level terminal handling library.

If someone else is able to implement this, I'd respectfully suggest sticking with less's nomenclature, and re-using the same command-line options, as this behavior will be very familiar to anyone who's ever wished that man somecommand or less somefile didn't clear the screen after you quit, and found this solution in the man page.[^fn1]

[^fn1]: If you put export LESS=RX in your shell's login scripts, that solves this problem and allows less to interpret ANSI escapes (like colors), too.

ernstki avatar Dec 22 '23 15:12 ernstki