Edward Loveall

Terminal Marks

There’s a feature I love in the macOS Terminal emulator that very few other emulators offer: marks. The ability to “mark” a line so you can use it later, kind of like a bookmark, is something I use multiple times a day.

Scroll back

One great thing about marks is I can easily get back to them. As a developer I’m often looking at large logs that contain more information than I need. However, when you do need that information it takes a bit of digging to find a useful point to start.

Like, say I’m trying to figure out what requests get sent to the server when I load a specific page. What I do is set a mark (⌘-U in the macOS terminal) then visit the page. Now going to the previous mark (⌘-▲) scrolls back to just before I visited the page. I’ve very quickly found the place I want to start from without having to scan potentially hundreds or thousands of lines.

Command history with output

What’s great is that you can set this up to add a mark to every command you run. (This might be the default, I’m not sure.) This makes it easy to navigate backwards one command at a time and see what you typed and what the output was. Scrolling up does this too, but it’s a difference of semantics. Scrolling has line semantics: it scrolls X amount of lines per scroll movement. Marks have command semantics: it moves one command at a time regardless if the output was 1 line or 1000.

Clear to previous mark

Another thing I do is make typos. whic instead of which puts text on my screen that I don’t need to keep. Some mistyped commands can even put lots of text on the screen which makes it harder to compare two outputs.

I can always clear all the scroll back, but I may want some of it. Clear to previous mark (⌘-L) gets rid of just that one mistake instantly.

Other terminals

I’m surprised that almost no other terminal emulator does this. iTerm does this (with some setup) but it’s subtly different than the macOS terminal, and I think a little clunkier. Clear to previous mark only clears the output not the command, so the bad command remains there unless you clear again. Still, I’m glad it exists.

Semantically marking each command seems like such an improvement to me over manual scrolling. I’d love to see it implemented more widely.