command clear -x assumes your clear executable supports -x like mine does.If there is any problem with this command then the function will only call command clear -x. When it overrides, the function prints just the right number of newlines to move the previous content out of the screen then regular clear -x is invoked to clear the newlines and place the prompt at the top. The function overrides the clear command when invoked without arguments it falls back to the command otherwise. It seems you don't want to clear anything you want to move text out of the screen and place the prompt at the top. Solution 2: custom clear as a shell function Note using the scrollback buffer of tmux is in many aspects different than using the scrollback buffer of a terminal emulator. It may be a major change in how you work in terminals. The tool is a terminal multiplexer, I use it routinely because of its other features and I had to explicitly get out of it to write some parts of this answer. My tests indicate it behaves the way you want (at least when clear sees $TERM as screen). Even if you could do this, I wouldn't say it's the Right Thing in general. Maybe you could find a different value of $TERM so your clear consulting your terminfo database will be able to make your terminal emulator do what you want. So maybe your clear does not print \033[3J or maybe it does but your terminal does not clear the buffer fully anyway. your clear seems to do what my clear -x does: it does not clear the entire scrollback buffer, only the visible part. My point is: clear prints different things, depending on what it "thinks" your terminal is then the terminal interprets these things and it may react in whatever way. I deduce tmux is a terminal emulator that reacts the way you want. But outside of tmux (in my case with scrollback buffer provided by Konsole) the same sequence replicates your problem. This sequence does what you want when interpreted by tmux. Inside it $TERM expands to screen clear and clear -x are both equivalent to printf '\033[H\033[J'. I often use tmux, it implements its own scrollback buffer. You can write a terminal emulator that reacts this way. Maybe there is an option that lets you choose. Even if clear prints \033[2J, the terminal may react by doing what you want. for some value of $TERM) print a sequence that does what you want.Īnd then there is the terminal (terminal emulator). It's not impossible some implementation(s) of clear in some circumstances (i.e. With printf we would need to do this manually. The very point of clear is it checks $TERM in the environment and then looks in the terminfo database (see man 5 terminfo) to determine how to clear the screen. In any case we could build and use an equivalent printf command. Anyway clear "thinks" the terminal is ztx and for ztx CNL is the best choice. Maybe it does in a real ztx or it doesn't, I don't know. Which does not clear the screen in my terminal. Moves cursor to beginning of the line n (default 1) lines down.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |