HOWTO: Use screen and irssi

Basics

What is a terminal?

A terminal is the system device that is created when you log into a machine. A terminal is connected to a process, which is most always a shell.

What is a shell?

A shell is an application (most likely zsh or bash) which takes commands and interprets them. A shell is (almost) always attached to a terminal.

What is a program?

A program like irssi is spawned by the shell when you type 'irssi'.

Life without screen

When you log into a Linux machine using ssh, it automatically creates a terminal AND an shell and attaches them to each other.

Ordinarily, when you log out of a machine, the shell is destroyed, and then the terminal goes away (gracefully). So does any process running in the shell. This is bad if you want to keep a process (irssi) running when you log out.


        +---------------+
        |   Terminal    |
        +---------------+
               ++
               ||
               vv
        +---------------+
        |     Shell     |
        +---------------+
               ++
               ||
               vv
        +---------------+
        |     irssi     |
        +---------------+

What does screen do?

Screen inserts itself ABOVE the terminal, so that the terminal never goes away. When you log out, you remove the controlling terminal for screen, not the one that controlls the shell that controls irssi. Since screen knows how to deal with a detached controlling terminal, your irssi never goes away:


        +---------------+                             +---------------+
        |Terminal @ Home|                             |Terminal @ Work|
        +---------------+                             +---------------+
               ++                                            ++
               ||                                            ||
               vv                                            vv
        +---------------+                             +---------------+
        |     Shell     |                             |     Shell     |
        +---------------+                             +---------------+
               ++                                            ++
               || <------- "Detach" and                      || <------- Attached simultaneously
               ||          "reattach" here                   ||           is -x. Automatically
               ||                                            ||           detach home when you
               ||                                            ||           attach at work by using
               ||                                            ||           screen -d -r.
               ||                                            ||
               ||                                            ||
               |+-------------->+---------------+<-----------+|
               +--------------->|    SCREEN     |<------------+
                                +---------------+
                                       ++
                                       ||
                                       vv
                                +---------------+
                                |   Terminal    |
                                +---------------+
                                       ++
                                       ||
                                       vv
                                +---------------+
                                |     Shell     |
                                +---------------+
                                       ++
                                       ||
                                       vv
                                +---------------+
                                |     irssi     |
                                +---------------+

Screen commands

Irssi startup

If you are starting fresh (screen -ls shows no screens running):

screen 
irssi
(inside irssi) /connect 
(inside irssi) /join #somedumbchannel

If you are reattaching an existing screen

screen -d -r

Troubleshooting

If your screen/irssi/terminal/shell locks up, you probably pushed CTRL-S. Push CTRL-Q to fix it.

<@Fitch> if you are a tard and type ctrl-s without meaning to, put stty -ixon in your .profile