Tabs when using ‘screen’

gnu-screen

I am using Ubuntu 10.04. After I installed screen:

sudo apt-get install screen

I made two ssh connections to two remote servers by doing the following things step by step (I do the following steps according to the document here):

1. open a termnal window, run command screen

2. press Ctrl+A+c to create a new virtual console

3. ssh usr@IP1

At this point, I have one virtual console which shows I have connected to the remote server(IP1).

4. press Ctrl+A+c to create a new virtual console

5. ssh usr@IP2

So, now I have connected to two remote servers(IP1 & IP2). But, I do not have two tabs on one terminal window, instead, I have to use Ctrl+A+p and Ctrl+A+n to switch between the two virtual console in one terminal window.

Isn't it so that by using screen, I could have two tabs in one terminal window, with each tab display one connection to one remote server. Why I do not have the tabs in my terminal window?

Best Answer

Here's my .screenrc that i use everywhere to see my screen numbers as tabs at the bottom of the window and an informational line above the tabs. The part you really need is under "look and feel".

# skip the startup message
startup_message off

# go to home dir
chdir

# Automatically detach on hangup. 
autodetach on

# Change default scrollback value for new windows
defscrollback 10000

# start with visual bell as default
vbell on
vbell_msg "bell on %t (%n)"

# look and feel
caption always "%{= bb}%{+b w}%n %t %h %=%l %H %c"
hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"

activity "Activity in %t(%n)"

shelltitle "shell"
shell -$SHELL

You could additionally add the following to automatically add two tabs when the screen is initially created:

screen ssh usr@IP1
screen ssh usr@IP2

Also, the status content can be updated using escape codes issued from shell commands and prompts. For example, i update the status with the current directory using by using this in my .bashrc:

if [ 'screen' == "${TERM}" ]; then
  export PROMPT_COMMAND='printf "\e]2;%s %s\a" "${USER}" "${PWD}" '
fi
Related Question