26

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?

5 Answers 5

31

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
1
  • 5
    I've always wondered why it invariably takes some hardcore configuring in order to make screen not suck to work with. P.S. Try shelltitle "$ |shell:" for appending the command name to the title. Dec 8, 2011 at 1:56
10

When you press Ctrl+a and " you can see the screen "tabs", they aren't supposed to be tabs on your terminal GUI, you can do that manually by creating a new tab at the terminal GUI you are using and then run at the new tab screen -r to return to your screen session and then navigate to your desired session with Ctrl+a and a number or " to see a menu with all your tabs.

You can give a name to each one of you screen "tabs" by pressing Ctrl + a then A .

1
  • 1
    Should need to run screen -r -x if that screen is already attached in the first tab.
    – Arcege
    Dec 7, 2011 at 12:23
3

I guess you are confusing the tabs on graphic terminals like konsole with those in screen. In screen you switch only the content of a window with the mentioned ^A-Kombinations. This works also on a non graphic environment.

3

I know this is quite old, but since Google led me here, others may read this too. So here's my $0.02 hack to mimic tabs within a "screen" session :

Build a status line with :

  • on the left side : date/time
  • on the right side : local host name + average load
  • in the middle : the names of the screen "windows"
    • current window : red text on black background
    • other windows : white text on status line background color (blue, here)

Put in ~/.screenrc :

hardstatus alwayslastline "%{kb}%{c}[%{w}%D %d/%m/%Y %c:%s%{c}] %{w}%-w%{rk}%n %t%{wb}%+w %=%{c}[%{W}%H %l%{c}]"

(Maybe this is worth more than $0.02 because I struggled quite a time on this ;-)

To switch from the current window to the previous / next with F6 / F7 keys :

bindkey -k k6 prev
bindkey -k k7 next
2

You could configure screen to show a status line that can inform you of many things, I suppose also on which screen window you are, but I don't use a status line, so cannot say for sure.

For what I know, screen do not create tabs, but you have to switch between screens with the command you indicated, or as I prefer Ctrl-A 1, Ctrl-A 2, etc.

To have more that one tab you can use gnome-terminal features, also without screen: Ctrl-Shift-T will create a new tab, and Alt-1, Alt-2, etc. will switch between tabs.

Also I ask why don't you run screen on the server, so using only one ssh connection (but in this case without any tab).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .