1

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:

  • Run reset before the command, then use Ctrl+Shift+Home after executing the command to jump to the top of the terminal, as given in this answer.
  • Pick a different terminal that supports searching, as per this answer.
  • 1
  • Wow, the workaround mentioned there is actually the best I've seen so far. I will use that for now. In the meantime, I wonder if any more direct solutions have come up in the last couple years. – Apollys Jun 19 at 19:05
  • "Search upwards [...] don't know if it's possible in gnome terminal", "Pick a different terminal that supports searching" – Hey, gnome-terminal has a toplevel menu called Search. – egmont Jun 20 at 6:19
  • As you've never accepted an answer before: If this answer did help, just click the little grey at the left of this text right now turning it into beautiful green. If you do not like the answer, click on the little grey down-arrow below the number, and if you really like the answer, click on the little grey ☑ and the little up-arrow... If you have any further questions, just ask another one! ;-) – Fabby Jun 27 at 7:32
4

Erm, you can do that with the standard gnome-terminal:

Search animation

The only thing I did was to press Ctrl+Shift+F to start the search and the standard is Backwards already...

Just ensure that you have enough scrolling lines available to scroll back to by changing the scrollback limit:
EditProfile PreferencesScrolling
8192 just takes a few KB of RAM so enter whatever number that suits you there!

gnome-terminal settings

Also: for short hops up and down, don't forget about Shift+PgUp and Shift+PgDn even while you're compiling. (No, it will not pause compiling: just add lines out of your view...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.