Screen configuration file .screenrc – super basic example

Posted: 2012/09/07 in Linux
Background:

I was introduced to the screen command by Ian Maddox of Seattle PHP Users Group / Meetup Group fame (Ian’s Profile). I started using it for two purposes, both having everything to do with disconnecting from the ‘session’: (1) for long-running tasks where I wanted to go do something else (ex. massive file copying) and (2) whilst on my mobile phone wherein I had no confidence I would keep my connection while doing, well, massive file copying (I guess that makes this one reason!).

I quickly mastered Ctrl-A d (detach)

But now I want to reattach to a session (from the command prompt: screen -r) AND scroll-back.  On most of my current set-ups, when I reattach and try to scroll-back, I don’t actually scroll back in the reattached session – I just see the first page-full and then I see all the stuff I was doing before screen -r.  Off to the man-page.

A little poking around revealed the ability to use vi-like commands to scroll around.  My down-and-dirty approach:
           Ctrl-A [  (left-square bracket)

Then ‘j‘ and ‘k‘ for up & down (respectively) a line at a time.  Ctrl-u / Ctrl-d for pageful(ish) at a time.  All kinds of other great things in this ‘vi like mode’.  Sweet.  I can even do this from my phone’s ssh terminal!!

But since I am doing massive file-copying (or, in today’s case, an indexer of thousands of rows all with status data as each row is processed), I want to be able to go back more than the default 100 lines.

Enter the config file — .screenrc

There are a number of files that are read for configuration whenever screen is started (see the man page).  For my simple needs, I just created .screenrc in my user directory (that is, ~/.screenrc).  Here’s my super-simple, current use-case-fulfilling example file:

# see http://linux.die.net/man/1/screen for details

# don't kill the session when my phone looses connection
autodetach on

# override the default 100 lines of scrollback
defscrollback 5000

That’s it.  There are so many other great options/additions (I like defmonitor on, for example).  But I don’t use screen every day so I tend to forget most of the cool things it can do.  Scrollback, though, that’s a big one for me.

could use Ctrl-A i to turn on logging, or instantiate logging when starting screen, but that’s more work for me – cleaning up log files, etc. (my life is SOOO difficult, I can’t be bothered with such tasks (sic)).  So here’s my simple fix: massive scrollback.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s