(no title)
broses
|
3 years ago
A while ago I was trying to find a way to make my terminal scroll back up after a command executed, so that if the output was long I could read it from the top without having to scroll up manually. There are ways to get yours shell to print something after the command executes, so I just needed to find an ansi escape sequence that would scroll up. Unfortunately I didn't see any sequences that do this. Anyone have any ideas?
bee_rider|3 years ago
your_command_here | less
It will capture the output and let you scroll up and down.
Otherwise, this would really be a feature of the terminal, and not necessarily required to be supported (it makes sense when you consider that many early real terminals literally printed the output to paper -- who needs scroll-back, just look up the tape! And repeating previously shown output would result in a confusing print-out).
However, if your terminal emulator doesn't have a scroll-back, you could try something like tmux, or alternatively gnu screen. These add lots of little features to the terminal (a buffer to scroll back, split terminals, persistence so you can detach and reattach) (tmux is more modern feeling, IMO).
duskwuff|3 years ago
csdvrx|3 years ago
Assuming you tried moving the cursor vertically, have you tried the alternative approach of Store Cursor Position / Restore Cursor Position cf https://stackoverflow.com/questions/28986776/ansi-escape-seq...
The scrollback buffer may be a limitation, so you should try with enabling or disabling the alternate screen (ti/te)
If that fails, you may have to tweak your terminal emulator to "hook" the SCP/RCP to a specific point of the scrollback buffer, to allow this scrollback.
midislack|3 years ago
hnlmorg|3 years ago
You'd be better off piping into less / more / most. These are called "pagers" and are designed to do this. eg
bowmessage|3 years ago
rustyminnow|3 years ago
(Also handy: add in `-X` to leave the contents on the screen when you exit less)
SoftTalker|3 years ago
aumerle|3 years ago
d0mine|3 years ago
mikevin|3 years ago