Wednesday, July 07, 2010

GNU Screen Commands Redux

Some important commands for GNU Screen, the text-based output multiplexer:
To do this...Do this...
Make a new session/reconnect old onescreen -U -dRR sessionname
Detach sessionC-a d
Split horizontallyC-a S
Split vertically(!)C-a |
Remove this split regionC-a X
Remove all but this split regionC-a Q
Jump to next split regionC-a Tab
New windowC-a c
List windowsC-a w
Copy mode/pauseC-a [
Filtered from here.

There are of course more comands that GNU Screen supports, but these are the few that I find to be most useful especially when working over a ssh link, since I can monitor several outputs at the same time. Bear in mind that due to the nature of multiplexing, having split screens/regions can cause a slow connection to appear a tad slower.

2 comments:

Mo said...

I've recently started using screen quite often. I've found it useful to be able to identify by prompt which screen you're in. As such, I've written a script that can do that. Just add this to your .bashrc:


# Fix prompt to prepend screen name when necessary.
pid=`ps -f | awk -v pid="$$" ' $2 == pid { print $3 } '`
scr=`screen -ls | awk -F "." -v pid=$pid ' $1 == pid { print $2 } ' | awk ' { print $1 } '`
if [ -n "$scr" ]; then
PS1="\[\033[32m\]$scr:\[\033[0m\]$PS1";
fi

I hope text formatting is preserved in the comment.

The_Laptop said...

That's nifty, but more often then not I know which screen I am currently on; that's why I use "C-a w". I try to minimise the amount of customisations that I do to a system -- this helps with me being a little more versatile, not forgetting that I have effectively 3 to 5 machines to work with each time.

I don't think the formatting was preserved. I think they really went all out to prevent injected code via comments.