How to scroll completely to the top of large terminal text buffers w/o adding additional dependencies? - shell

I have a couple shell scripts which output git diffs which can get very long. When this happens, the terminal is left scrolled to the bottom of that text.
Ideally I'd like to programmatically scroll to the very top of the text buffer in a way which is as platform independent as possible, without requiring additional software installation.
The following works to move cursor to top of the currently visible text, but not to the top of the entire text buffer:
printf '\e[H'
This does basically the same thing:
printf '\e[0;d'
But neither of these scroll completely to the top, they just move the cursor to the top of the visible text.
My platform dependent (macOS) workaround is here:
https://github.com/montehurd/gitshorts/blob/main/utility#L3
Any pointers for how to scroll to the very start of the text buffer?

Related

InteliJ IDE 2021.2: How to adjust the header vertical space usage?

Is it possible to adjust the header rendering in InteliJ. Currently almost a centimeter of vertical is completely wasted to emptiness (Which is significant when working on the 15 inch mac laptop).
Going 'Full Screen' isn't acceptable option right now since then then it adds transition delay when going to another window like the terminal.
Try Distraction Free mode: https://www.jetbrains.com/help/idea/ide-viewing-modes.html
In Distraction-free mode, the editor occupies the entire main window with the source code centered. All other elements of the UI are hidden (tool windows, toolbars, and editor tabs)

Stop XTerm from moving text upwards on window resize, when cursor is at last row?

In the Alternate Screen Buffer mode in XTerm-like terminal emulators, when the cursor is on the last row and the terminal window is resized so that it has less rows, all text in the terminal is shifted upwards.
Can anyone point me to what is going on here? I can't find any related escape sequences to turn this behavior off, or any way to intercept SIGWINCH to move the cursor before the shift happens. It seems like it may be related to scrolling to keep the cursor on the screen.
I'd really like the screen display to not change, even if the cursor is no longer on screen after a resize.
I'm not using ncurses or other libraries, just escape sequences and system calls.

Neovim - Closing buffers/panes like Ag leaves trail of it behind

I am using NeoVim in iTerm. Whenever I open any temporary panes like Ag to search for some text in my project, after selecting an occurrence from the list, I notice it leaving some parts of the old buffer left behind. (screenshot attached) It gets fixed when I navigate through the entire affected area of the buffer using j,k or Up,Down.
My vimrc: https://github.com/AvinashKrSharma/dotfiles/blob/master/vimrc

Printed contents disappear in terminal

The thing is I have printed something in the terminal, but when I accidentally resize the terminal, the printed contents at the bottom of my terminal disappear. Why is that? Is there anyway to recover these printed messages since the program runs a long time each time.
When you resize a terminal window, the terminal has to paint or repaint part of the window. If you lost text at the bottom of the window, that sounds as if you shrank the window when using one of the terminals which leave the upper-left corner of the window in a fixed position, while adjusting the rest of the window. Offhand, that could be rxvt, putty, konsole. xterm (which is configurable) defaults to the other direction.
If the window shrinks, then the location of the "bottom" row of text should be moved up (to match user's expectations). But there is a complication: GNU screen will besides redrawing the window, attempt to wrap long lines so that they fit the new margins. Developers for a few terminals have imitated that in the past few years, and you may notice some bug reports when that new feature does not work well.
For instance, if you shrank the window vertically, but changed its width, then a miscalculation of the wrapped lines could cause text to vanish. Then again, resizing it again might get the text back into view. But if that does not work, then it's gone.

Shift browser contents to the left while viewing in wide screen

I use a widescreen laptop. Many websites have their content centre aligned. On wider screens this means lot of empty space on left and right. As such this is not a botheration.
Many a times, I read some instructions on the web page and type them out on the command prompt. I prefer to overlay the command prompt window on top of the browser and if the browser contents are left aligned (or right aligned), then I need not Alt-tab across these windows.
I use Firefox on Ubuntu. I use the command line (konsole) heavily. I know compiz (and similar) tools provides transparent windows so that the content beneath is visible. But I don't want to install compiz or its equivalent because my graphics driver is not all that good.
Any addon or simple trick that would shift the page content to the left (or right) would be very helpful (read productive).
The path of least resistance is: Don't maximise the window - leave it as a floating window and move it over so it is side-by-side with your command prompt.
If you really want to be funky, override the stylesheet using a user defined stylesheet that has a fixed margin on either the left or right, so the space is never used by the web page.

Resources