Closed simurgh9 closed 2 weeks ago
clear
should not mess up the buffer. When it works as it should, clear
just opens a new prompt because, while it clears the terminal, the MisTTY buffer displays keeps a log of previous terminal states, so you just don't see anything. So you get something like the following in the buffer:
$ clear
$
At least that's what happen in my tests. I'd like to look into why it doesn't work that way for you. What does it mean that it messes up the buffer? Could you give an example? What's the value of the TERM env variable? What shell are you running? Which version? Which version of Emacs and MisTTY are you using?
Maybe when MisTTY detects a clear
or reset
command, it should call (recenter-top-bottom 0)
(or 1 for multi-line prompts) so that only the prompt is visible - but the history remains in the buffer. I could definitely add something like that, but first it's important for clear
to not mess things up.
In the meantime, in case you type clear by mistake in a MisTTY buffer, you could add the following to your .bashrc or the equivalent for your shell if you don't use bash:
if [ ! -z "$INSIDE_EMACS" ]; then
alias clear="echo disabled for now";
fi
Here is some info,
Version: 1.0.9
GNU Emacs 29.4 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.60 Version 12.6.6 (Build 21G646)) of 2024-08-02
Here is how it looks,
Btw the vterm people also be doing some special to handle a clear. I am running zsh
and echo $TERM
yields eterm-color
.
I can reproduce the problem and I'm working on a fix. The issue seems specific to clear on zsh; reset works. The screen grab was very useful in understanding what's going on. Thank you!
BTW since we are doing this. It would also not be a bad idea if when exit
is ran, the mistty window is also quit.
BTW since we are doing this. It would also not be a bad idea if when
exit
is ran, the mistty window is also quit.
Yes, it might be a good idea to add some hooks to allow tracking the process state. I'll add that separately from this issue.
With the latest commits, "clear" should work, even on zsh, and empty the window. Please give it a try and let me know if something's not working for you.
The changes are also available on melpa, starting from 20240902.959.
BTW since we are doing this. It would also not be a bad idea if when
exit
is ran, the mistty window is also quit.
This can now be turned on as described on: https://mistty.readthedocs.io/en/latest/extensions.html#mistty-after-process-end-hook
I often end up running clear by the force of habit and it messes up the buffer. Is there a way to make this command run as intended, i.e., clear the buffer/terminal?