Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Why does zsh clear to end-of-screen after prompt?
- X-seq: zsh-users 29199
- From: John Hawkinson <jhawk@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: Why does zsh clear to end-of-screen after prompt?
- Date: Fri, 25 Aug 2023 20:59:20 -0400
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 18.7.68.33) smtp.rcpttodomain=alum.mit.edu smtp.mailfrom=alum.mit.edu; dmarc=pass (p=none sp=none pct=100) action=none header.from=alum.mit.edu; dkim=none (message not signed); arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K6kzkG/kLajMsNYzTG16k5t0X0zqs61rhnbYRf4j7OU=; b=TqodTgF/KrT/s0AVwVNGEJIpKphe62sUk+NsfQlvXIMlqeKGp2uH+CrzraQH5tVyJdDJSbVNN0ADW1QhLMsx0INtIbJBDehU7WaWBCgYhVodFSmG9jTOlibXiFvSK+MdGZanC3oWkdg9h56nSk+9KPA9XdvsLkdz4krLarPRKngr5PNn8oKGgVHyULw+1s6sbfXGZH5OhJpLDq2wI4EQ5Z13r9bbllyGXhtn5PRzJhXZ4YGWBYQW9nUR3ncH8278EykCkzwzbRTkcj5Kg5InS6Mnrz2ZauNz/HAZOjwRWT4MF2zVo+FY5HiIW4PoPqdQDP/cOTSX/K6ZjXLY03gRdA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nf7AokLh4vzuvRqvffxpFKDzUsW9ur2DQxOX5+CQhnwBZV2TkqRhWnx6k0GxdrQd/RwY0ACciwNzuTAgO754R0KRYOGFr1MyZxQXFC1fBVbeETWwf6BS9LpgzVOthzcQbsgs69/gCcUdoEDCILUsVb+g3sdhqkW8a3e2JOHmIUyS5OKS3Mdh06UGl4Jht1E90D7RBIjFWedeoUSD6JqqOEph0zLmI/PGzR6t0WL7kM+KLTztjWPYogvRIUGVqd7b2qNBa7lgJKYOcoh//0D7fyivEik3rV0T5FLsqDWbxGeX2eW4aNzT4UIoRir2kJs+yuRf3sbR0iB5eASSvXXbiQ==
- Archived-at: <https://zsh.org/users/29199>
- In-reply-to: <CAH+w=7ZQaJgvk=wLX5mVEC4XR3AP1kxZU+t6O88PZFAZ6p6w9Q@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <ZOkGi5f6hPuk_1-b@louder-room.local> <CAH+w=7ZQaJgvk=wLX5mVEC4XR3AP1kxZU+t6O88PZFAZ6p6w9Q@mail.gmail.com>
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote on Fri, 25 Aug 2023
at 20:18:01 EDT in <CAH+w=7ZQaJgvk=wLX5mVEC4XR3AP1kxZU+t6O88PZFAZ6p6w9Q@xxxxxxxxxxxxxx>:
> This happens because ZLE is a mult-line editor and also because
> completion uses the space under the editor area to display lists etc.
> If the screen were not cleared, text being edited could mingle with
> the screen contents already present.
Ugh. I suppose it would be too much to ask that it not do this in the (for me) 90+% case where neither completion nor multi-line editing have been used?
Or only to clear as many lines as have been used, rather than to end-of-screen?
Or a knob to just not clear it and let the user deal with the fallout?
I was optimistic that
setopt SINGLE_LINE_ZLE
would solve this, but it does not.
Oddly
setopt noZLE
does so, but it's a worse user experience than TERM=dumb.
At least with TERM=dumb I get up/down arrow, even if the editing is not quite right and overlaps the prompt in weird ways.
> > How can I get cursor positining to work without forgoing, e.g., line editing?
>
> You can try something like this:
>
> PS1=$'%{\e[H%}'$PS1$'%{\e[K%}'
Bah. I mean, yeah, that works, but it feels fairly not-great.
In case it wasn't apparent, the use case is I had a small ad hoc script that produced ~20 lines of key/value output and sometimes the values change and I'd like to keep them in the same position on the screen and just overwrite themselves when they change if I rerun the script with up-arrow/RET.
I guess another way is this:
OPS1="$PS1" # save it for idempotency later
PS1=$'%{\e[40H%}'$OPS1
echo '\e[H'; seq 1 20
which, for an 80x48 window, gives 8 lines for editing and commands that don't do any positioning, and leaves the top 40 lines for stuff that's prefixed by CSI H homing to the top-left. Maybe this is an acceptable balance, I dunno.
> There are also games to be played with save_cursor and restore_cursor,
> e.g., a command that wants to control the screen appearance could move
> to a position, save_cursor, and then move to the end of the screen, if
> the prompt were then programmed to start with a restore_cursor -- but
> you still have to be careful about that "start in the leftmost column"
> and deal with avoiding the restore if the last command didn't save.
Yeah, this feels even more...antithetical to the simplicity I was desiring.
Honestly it feels like just using bash for this particular one-off is the easiest way out :(
It seems to me, also, that the documentation could use some improvement on this point, but perhaps it is so obscure that it is going to be hard to find a good place to insert a straightforward discussion of this concern. If this thread doesn't reach any better resolution I'll do some thinking about ways to improve that.
Thanks, Bart.
--
jhawk@xxxxxxxxxxxx
John Hawkinson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author