This is a question I've had for around a decade now and I've never found an answer. To make it specific though, I'll ask in the context of my current environment.
On Ubuntu 16.04, using the gnome terminal, is there a way to jump to the beginning of the output of the last command you ran or to the line containing the last command itself? Ideally I would like to assign this action to a convenient hotkey.
Obvious use case: anytime you compile something and get more than a screen of errors.
This is so simple, but I haven't come across a way yet. Some pathetic alternatives:
- Redirect output to file, then open the file in an editor. Problems: adds developer time/overhead/annoyance; probably lose bash formatting when opening in file, making output harder to read; overall generally negating time saved over just scrolling up.
- Pipe to
less. Problems: same as above, plus it doesn't seem to start at the top of the output or let me scroll properly.
- Pipe to
grep -i error. Problems: likely won't show the relevant lines of the error message (need successive lines), any grep solution is not robust in general, and again adds overhead.
- Search upwards in your console for
username@computername? Problems: don't know if it's possible in gnome terminal (other terminals can do it), not robust (though pretty good), maybe slow to type.
Have people really been scrolling up to find their error messages all these years? I feel I must be missing something.
Edit: best alternatives so far: