Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to scroll back the terminal to where the last command was given?

I've got a program which has a lot of output. Once it's done I often want to scroll back to the begin of the run so that I can look at some things there. Since the output is so long though, I see myself endlessly scrolling with PageUp and trying to drag the scrollbar on the right to the point where it could have begun. Over a while this starts getting quite tiresome, so I wonder:

Is there a way to easily have the terminal scroll back to the part where the last command was given?

like image 340
kramer65 Avatar asked Jun 20 '13 11:06

kramer65


People also ask

How do I find previous terminal commands?

Open a terminal application on your Linux or Unix and type history to list all commands. To search for a command in the history, press ctrl+r multiple times. For instance, you can hit the ctrl+r and type string to search.

How do I go back to a previous terminal in terminal Mac?

Type "cd -" in the Terminal window and press "Return." The Terminal returns to the previous directory.

How do I go back to a previous command in Linux?

Using a Reverse Search of Linux Command History To enter this mode you simply press ctrl and r. You can then enter a search term and use repeat presses of ctrl and r to step back through the list of previous commands containing that term.

How do I go to previous page in terminal?

Use Shift + Page Up and Shift + Page Down .


2 Answers

I have just found this in Terminal for OSX:

Edit > Navigate > Jump to Previous Mark: cmd + UP.

like image 129
Skylark Avatar answered Sep 22 '22 02:09

Skylark


I use iTerm2 in macOS, I came up with a method. First, you should make sure you check the Unlimited scrollback in iTerm2's preferences. enter image description here

After you run a command in terminal and got a long long output.

Press Cmd+F(maybe ctrl+F in windows) then your can search in terminal like this:

enter image description here

Finally, just search your user name and press Enter, generally speaking you will jump to the last command:

enter image description here

like image 34
sirius Avatar answered Sep 21 '22 02:09

sirius