Hey so maybe I need to understand how the marks work in the terminal app on mac.
Basically I ended up getting a huge error message when I was doing something. Is there a way to get the cursor (including especially that of VO) to just after the initial command I have typed and so just before whatever output I get so I can read it from the beginning?
Thanks a lot!
By TheBllindGuy07, 17 December, 2024
Forum
macOS and Mac Apps
Comments
Scrolling with page up/down…
Scrolling with page up/down or the 3-finger gestures and dragging the finger on the trackpad is a good temporary workaround. Like the beginning of the error was on page 3/10! :)
If it helps
You can also save a print out of the terminal window to a dot TXT file, usually saves in your documents folder. I think it's just command plus S, if I am not mistaken.
Redirecting Output
First, make sure you are working in a tab rather than a window. For reasons I haven't figured out yet, vo seems to work better in a tab.
For large outputs, it's best to pipe or redirect it to a file or into a pager such as less. Sence you know that the output is sent to the error stream (stderr), you can just repeat the command in question with the following added to the command line: 2>errors. That will direct the output from stderr to a text file called errors that you can read at your leasure.
It's worth noting that the vo command to go to visiblal beginning vo-shift-home seems to be broken at the monment. It jumps vo to the vary beginning rather than the visible. So, to get to the beginning of an open file in the terminal window, you will need to first vo-shift-home, move vo forward a bit with vo-right, then find the beginning with vo-shift-end.
Thank you. Oh I thought that…
Thank you. Oh I thought that vo-shift-home wasn't behaving normally too. Will send yet another feedback to the golden apple! :)
Edit: FB16116977
My terminal tips
I actually use the vanilla MacOS Terminal a lot, so here are a few tips that I can share from the top of my head:
The first thing I recommend is to download TextMate. Even if you don't use it for coding due to its lack of support for language servers, it's still useful to use as a dumb pager or just pipe long output to, and in my experience it's fully accessible. TextMate has a command-line utility called
mate
, installed from its Preferences window, that can be used to open files in or pipe output to the editor from terminal, and there's even a remote script calledrmate
that can be used to do the same from remote systems.With TextMate installed and properly configured, reading long output is just a matter of using shell redirection to pipe it to the aforementioned
mate
orrmate
utilities as mentioned earlier by Blade Runner. For example if you want to fetch and display the HTML content of the front page of this site in Terminal you'd type something like the following:However the above would produce a very long output and even some diagnostic messages. Since curl sends diagnostics to
stderr
(file descriptor 2) and normal output tostdout
(file descriptor 1), you can get just the normal output sent to TextMate and leave the diagnostics in terminal using just a pipe as follows:Or you could even silence the diagnostic messages by redirecting them to
/dev/null
while still getting the output in TextMate as follows:You could even get both the output and errors sent to TextMate as follows:
In some situations, like when compiling a lot of code, you might want to follow the progress slowly unfold in Terminal and still get the final result in TextMate, and that is also both possible and easy to accomplish using the standard
tee
utility.The following example pipes the output through
head
to limit it to 10 lines, and then throughperl
to throttle the output to a single line per second for demonstration purposes, so it's a little more convoluted, but what matters here is the redirection throughtee
that also sends the output to terminal right before redirecting to themate
utility:My second recommendation is to set the
EDITOR
environment variable to make programs likegit
use TextMate when they need to invoke an editor, by adding the following line to your~/.zprofile
file:My third recommendation is to set the
PAGER
environment variable. The purpose of that variable, and other similarly named variables with utility-specific prefixes, is to automatically pipe long output to another utility that can be used to make it easier to read it. By default almost every program uses either theless
ormore
utilities, but I have mine set to call the aforementionedmate
utility to display the content in a TextMate window after stripping off all the terminal controls that do not make sense in plain text.At the moment I have the following two distinct
PAGER
-related definitions in my~/.zprofile
file, which I strongly recommend studying before actually using because I'm just a random Internet person that you should not trust by default:The
PAGER
declaration is for all applications in general, whereas theGH_PAGER
is a hack that I devised to work around a problem in the GitHub command-line client where it behaves in a non-standard way by not invoking a shell to interpret the defaultPAGER
commands. The regular expression used in the Perl invocation follows my interpretation of the ANSI CSI terminal escape sequences referenced at Wikipedia, and thecol
utility is a standard POSIX tool that removes or reinterprets all the remaining controls that my regular expression doesn't strip.