9

Suppose you type a command in terminal after Enter you will see a list which more than one page. Now you want to read the result from the beginning and you should scroll up. So if you put some commands before your last one its a bit difficult to scroll the the last one --at least for me -- So I need any key switch which show the screen from the last command.

ps: I want to screen show the last command by key switch. Is there any key switch like CTRL+ L which clear the screen. less command show the screen page by page.

0

6 Answers 6

11

There isn't one as far as I know. You have a few choices though:

  1. Pipe the output through less or more

    command | less
    
  2. Hit the up until you find the command you ran and run it again (optionally using less or more again).

  3. Run the previous command through less using history expansion.

    !! | less
    
  4. Use a terminal that supports searching through the scroll back. The image below is showing my preferred terminal, terminator (installable with sudo apt-get terminator) but Ubuntu's default terminal also supports this. Just hit Ctrl Shift F to show the search bar. If you then search for either the command's name or your username (which appears in your prompt) you will be taken directly back to the last command:

    enter image description here

0
3

Pipe the result through less,

some-command | less

From the man page;

Less is a program similar to more (1), but which allows backward movement in the file as well as forward movement.

2

So basically you want it to automatically scroll to the last prompt, and the command that was run from it? I don't think this is possible with current versions of terminal unless you use a find function.

However as an alternative, you can colour in the prompts so that it is easier to work out where they are: enter image description here

You can do this in Ubuntu* by going to the ~/.bashrc file, and uncommenting this line:

#force_color_prompt=yes

to:

force_color_prompt=yes

You can then save it and run source ~/.bashrc and see the changes straight away.

*In other Linux OS's, on versions of Ubuntu without this version of ~/.bashrc, just copy lines 31 to 78 (only most of it is needed) of this and then uncomment #force_color_prompt...

1
  • 1
    Tthats how i do it so I can read any long terminal outputs of my Linux machines that i SSH into. I think its enabled on Raspbian (A Raspberry Pi OS) for this reason as well. Thanks :)
    – Wilf
    May 20, 2014 at 19:40
0

If you're using gnome-terminal, what you can do is just copy the content of the terminal to a text file using "Edit->Select All" and "Edit->Copy".

Note: It will work only if you have set an unlimited scrollback.

Now open the text file in your favourite editor and find the previous occurrence of your shell prompt.

It's often easier to perform lookup operations in a text editor (amongst other things).

0

What about using a new terminal for every command? In gnome Terminal Ctrl+Shift+T Spawns a terminal in a new tab at the current directory.

0

If you can use Emacs, its shell mode keeps an infinite log of your input and output, which you can scroll back and forth through. It has a command ctrl-meta-L, or escctrl-L, which will usually jump back to the start of the output that follows the most recent line of input that you typed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .