parsed.org

Tips by tag: screen

Audible Bell by xinu on Jan 12, 2005 10:13 AM

To switch back and forth between the audible bell and the visual bell, run the following:

C-a C-g
bellkeystrokesscreenscreenrcterminal
Background Process by xinu on Dec 31, 2005 04:10 PM

If you need a process to survive your logging out of the system (or being knocked off of it), you can either screen it or wrap it with nohup. If you nohup, you'll lose control of it entirely, but the output will be written to nohup.out. With screen you can re-attach and take control later:

# nohup program -opts args &

-or-

# screen (press 'ctrl+a d' to detach after you've run the proc)
commandsloginlogoutnohupprocessscreenshell

Use these screenrc commands to bind specific key sequences to commands outside of the escape sequence (normally C-a). You can bind key combos to commands this way so you don't always have to prefix commands with your escape key sequence:

# Bind Control-PageDown to 'next', Control-PageUp to 'prev'
# to navigate between windows
bindkey ^[[5;5~ prev
bindkey ^[[6;5~ next

# Bind arrow keys Control-Down to 'next', Control-Up to 'prev'
# to navigate between windows
bindkey ^[[1;5A prev
bindkey ^[[1;5B next

(The keycodes for these keys can be obtained by running cat > /dev/null and pressing the desired key combination.)

bindingbindkeycommandsconfigurationescapekeystrokesscreenscreenrc
Change Default Escape Binding by cygnus on Jan 13, 2005 08:59 AM

The default binding is typically C-a. I like to use C-j:

escape "^j^j"

I also like to use C-j l to get a window list instead of C-j ":

bind 'l' windowlist -b
bindbindingescapegotchakeystrokesscreenscreenrcwindowlist
Keeping a Screen Open by cygnus on Jan 23, 2005 02:21 PM

You can use this in your shell dotfile (e.g. ~/.bash_profile, ~/.zshrc) to create a screen session when you log in or reattach to an existing screen:

if [[ $TERM != 'screen' ]] ; then
    if [[ `screen -list | grep -v "No" | awk '$2 { print }' | wc -l` == 0 ]] ; then
        screen
    else
        screen -dr
    fi
fi

This works in bash and zsh.

attachbash_profilebootconfigurationscreenscreenrcsessionshellstartup
Multi-user screen sessions by cygnus on Jan 12, 2005 10:00 AM

In a running screen, run:

C-a : multiuser on
C-a : acladd $user

Then run:

screen -x [pid]

to connect to (and control) the mulituser screen from another terminal.

keystrokesmulti-userscreensessionsterminal
Split Screen Resizing by xinu on Apr 03, 2007 08:22 AM

If you want to split screens and only need a few lines for one of them type the following after you use your control key (Ctrl+A by default):

:resize -10 (removes 10 lines)
gnuscreensplit
Split Screens by xinu on Jan 12, 2005 10:13 AM

While running screen, run the following sequence:

C-a S

Then run the following sequence to change focus:

C-a C-i

To collapse the splits to the one you're currently on:

C-a Q
keystrokesscreensplit
Windowlist Caption Alternative by cygnus on Jan 12, 2005 10:06 AM

This caption config line will add a "caption" to the bottom of the screen which will highlight the currently selected screen and show you a list of all the rest. Add it to your ~/.screenrc:

caption always " | %-w%{= BW}%50>%n %t%{-}%+w |%<"
captionconfigurationscreenscreenrc
RSS