Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use screen for my command-line tasks while managing the servers where I work. I usually run small commands (mostly file-system tasks) but sometimes I run more extensive tasks (like DBA).

The output of those tasks is important to me. Since I use Ubuntu and OS X (both Terminal Windows) for my tasks, yet I need to use screen, the scrolling is not available, so any long output (think a 500-row table from a select) is invisible for me. Mouse-wheel is out of the question.

When I say "scroll is invisible for me, I mean this:

top while using screen, in Mac OS X, while scrolling

I was thinking about two options:

  1. Pause (think paginate) the output of a certain command. When the output begins, it would let me read what's happening, then I press "Enter", then the output continues... until there's nothing more to show.

  2. Scroll inside screen. But I don't know if this is possible.

Of course, I don't know if those options are actually possible. If they are, how can acheive them? Other alternatives will be well received.

Thanks!

share|improve this question
up vote 81 down vote accepted

Screen has its own scroll buffer, as it is a terminal multiplexer and has to deal with several buffers.

Maybe there's a better way, but I'm used to scrolling using the "copy mode" (which you can use to copy text using screen itself, although that requires the paste command too):

  • Hit your screen prefix combination (C-a / control+A by default), then hit Escape.

  • Move up/down with the arrow keys ( and ).

  • When you're done, hit Return twice to get back to the end of the scroll buffer.

(If you move the cursor after hitting Return once, you'll be selecting text to copy, and hitting Return the second time will copy it. Then you can paste with C-a followed by ])

Of course, you can always use more and less, two commonly used pagers, which may be enough for some commands.

share|improve this answer
1  
I was just about to post about Copy / Scrollback mode (since deep in the manpage there's the reference) but you beat me to it =) — I found out that here (bit.ly/Lyg0yi) there's a nice explanation of how to use Vi-style commands for Scrollback navigation (Entering Scrollback Mode and Navigating section). Really useful. – AeroCross Jun 7 '12 at 17:53
2  
Also, pressing q quits copy mode without copying anything (and it's one less button press). This might be in the vi explanation but the link is now broken. – Nathanael Farley Jun 26 '14 at 8:59
    
i found another source for info: commandliners.com/2009/12/… – nocache Apr 30 '15 at 8:22
2  
Also pressing [Esc] exits from copy mode too. – Sopalajo de Arrierez Oct 6 '15 at 21:06
    
Google embeded this answer inside thier search result answer box thing. I found this and upvoted it but many googler's may never get here. :( – ThorSummoner Dec 13 '15 at 9:27

Using the screen buffer as pointed out by njsg is a good solution. You can also disable the alternate text buffer in the xterm termcap info inside screen. When disabled you can use the scroll bars (and mouse wheel) to scroll up and down.

Add this to your ~/.screenrc.

# Enable mouse scrolling and scroll bar history scrolling
termcapinfo xterm* ti@:te@

You can read more discussion here.

share|improve this answer
3  
Wow ― this is actually what I wanted. I'm gonna try this one out. I'll check back soon! Thanks for the tip! – AeroCross Jun 7 '12 at 20:34
    
Not working on Kali v2.0, and it seems doesn't work on Ubuntu v14 and above, neither. – Sopalajo de Arrierez Oct 6 '15 at 21:07
    
It's working well on ubuntu 14.04 – pylover Feb 21 at 14:48
    
Fantastic. Thanks for sharing. – phyatt May 18 at 18:07

I've had success getting basic paging by piping content to more, for example:

ls -l | more

Or, if you want color output for use cases like syntax highlighting, you can use

ls -l --color=always | more

This results in output that I can easily page through one screen at a time. I haven't tried @uther's modification to ~/.screenrc but that does seem preferable as a lasting solution when a mouse is available.

To try this out, you can go to this BusyBox emulator and then...

cd ~/bin
ls -l --color=always | more

Use the spacebar to page through the results of the ls -l command or use the enter key to move through results line by line.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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