Go back to the last command
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.
There isn't one as far as I know. You have a few choices though:
-
Pipe the output through
less
ormore
command | less
Hit the up until you find the command you ran and run it again (optionally using
less
ormore
again).-
Run the previous command through
less
using history expansion.!! | less
-
Use a terminal that supports searching through the scroll back. The image below is showing my preferred terminal,
terminator
(installable withsudo 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:
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.
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:
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...