I like tips that save a mouse drag, and this is the smallest one I know on the Mac. pbcopy takes whatever you pipe into it and puts it on the clipboard. You do not have to select text in the terminal or scroll up.
Copy a whole file, or the output of a command, and paste it with Cmd+V:
cat ~/.ssh/id_ed25519.pub | pbcopy
ls -la | pbcopy
It works the other way around too. pbpaste prints the clipboard, so you can pipe it into something else:
pbpaste | sort | uniq
One caveat: it copies exactly what the command prints, including a trailing newline. If that bothers you when you paste into a form field, use printf '%s' "text" | pbcopy for short strings. And be careful with secrets. The clipboard is shared with every app (and with Universal Clipboard, your other Apple devices), so I would not park a password there longer than needed.
Further reading: pbcopy and pbpaste (ss64), On this site: pbcopy and pbpaste connect the terminal to your clipboard, On this site: caffeinate stops your Mac from sleeping while a long command runs, On this site: Guide: keep your Mac apps in a Brewfile, so a new MacBook is one command away
Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more