Commands and their output
The terminal knows where each command starts and ends. Step back through them, go straight to a file an error names, or read what a command printed in the viewer, where it can be searched.
| Key | Action |
|---|---|
| ⌘F3 | Terminal's last output in the viewer |
| ⇧⌘F3 | Terminal's scrollback in the viewer |
Stepping through commands
⌘↑ highlights the newest command on the screen and everything it printed. Press it again, or ↑ and ↓, to step from command to command; past the newest, you are back at the shell.
While a command is highlighted, the keys are the application’s:
| Press | And |
|---|---|
| ↑ · ↓ | The command before or after |
| F3 | What it printed, in the viewer |
| ⌘C | Copies what it printed |
| Enter | Puts the command back on the line, without running it |
| Tab · ⇧Tab | The next or the previous file its output names — below |
| Esc | Back to the shell |
| Any other key | Back to the shell, which gets the key. Keys with ⌘ do what they always do |
- With a file lit, Enter and F3 are about that file instead — below.
- The highlight stays on the same command while more output arrives under it and old lines drop off the top. Changing the size of the window, or of its text, ends it.
- It works the same in the full terminal and in a terminal beside a pane.
- It needs the shell’s integration, which marks where each command starts and ends. Without it, a notice says there is nothing to step to — and says so too while a program holds the whole screen, which keeps nothing to step through.
clearerases the mark of the command it ran under, so what that command printed is no longer one to step to.
Files in the output
Every name in the highlighted command’s output that is a file or a folder on this Mac is underlined. Tab and ⇧Tab step between them, and the one you are on is lit.
| Press | And |
|---|---|
| Enter, or click it | A pane’s cursor goes onto it: the full terminal gives way to the panes, and a terminal beside a pane gives the keyboard to that pane |
| F3 | The file in the viewer, at the line the output named |
| F4 | The file in the editor, at that line and column |
| ⌘-click | As Enter, on a name in any command on the screen, without stepping to it first |
- What is taken for a name
- A path read from the folder the command ran in —
src/main.go,/etc/hosts,~/notes.md— with or without a line after it, as compilers andgrep -nwrite them:src/main.go:42orsrc/main.go:42:7. Brackets and punctuation around it, and a full stop after it, are left off. - What is not
- A bare word with no folder and no extension —
Makefileis not, thoughMakefile:12is. A name with a space in it, unless the output put it in quotes. Another user’s home,~alex/…, and web addresses.
- Only a file that exists is a link, and that is asked again as the output is read — a file deleted since stops being one.
- A command whose shell never said which folder it ran in has no links at all, and neither has one
that prints from another machine or a container —
ssh,mosh,docker execand the like. - F3 and F4 on a folder say so; Enter is how to go to one.
Output in the viewer
The terminal has no search of its own. The viewer has search, filtering and going to a line — so output goes there.
- ⌘F3 shows what the last command printed; F3 on a highlighted command, what that one printed.
- ⇧⌘F3 shows everything the terminal has kept: the screen, and what has scrolled off its top — how much is Lines kept above screen.
- Both work from the panes as well as from the terminal, and show the current tab’s shell.
- Each is written out the moment you ask, so what the viewer shows does not change under it. The last ten are kept, in a temporary folder only you can read.
- The last command’s output needs the shell’s integration, to know where it starts and ends.
- With nothing to show — no command has printed anything, or the terminal has not been used — a notice says so.
See Searching a file for what the viewer can do with it.
Copying what a command printed
- With a command highlighted, ⌘C copies everything it printed.
- Anywhere else, select with the mouse and ⌘C copies the selection — see Keys, mouse and clipboard.