|
|
Hacking IRC, Part 2 Author's note: Even if you're a busy person, there's still no need to have hundreds of console windows open at the same time. Console-based IRC clients are perfectly amenable to being used with the GNU Use IRC Within screenIf you're regularly on the move, you need a way to keep track of IRC while away from your computer. Run a console-based IRC client in screen as a simple yet powerful solution. If you're running a text mode (console) IRC client on a remote system, it can be annoying having to reconnect if your connection drops or if you have to move to another machine. When you reconnect, you will no longer see the messages that were sent when you were last connected. GNU screen provides a neat solution to this problem. It allows you to disconnect from a terminal session without quitting your running programs. You can then log in and resume the screen session at a later time, giving the appearance that you never disconnected. screen is provided as a package on most Unix-based systems. If it isn't already installed, install the screen package or download and install it from source at http://www.gnu.org/software/screen/screen.html. Starting screen is amazingly simple, yet many people overlook the usefulness of it. At a shell prompt, simply type:
If you get a startup message, just press Enter. You should then see a
shell prompt. This is just like any other shell, but with one
difference—every time you press Ctrl-A, it will be intercepted
by screen. All of
screen's commands are accessed
by typing a different letter after this key.
screen provides a short summary of the commands
if you press Ctrl-A followed by the ? key. These combinations are
often abbreviated to the form Probably the most useful command is the one that lets you
"detach" from a
screen session. Typing
You should now see the screen as you left it. You can also log out
completely, and later log back in and reattach. By default,
screen will also detach sessions when the
terminal is closed, so screen sessions survive
network connections dying and closing the terminal window. If for
some reason your connection dies and the screen
isn't detached,
screen's other great strength
is that it lets you run more than one program inside one terminal
window. This makes it easy to leave several programs running and
access all of them from another location, even if you are restricted
to a very slow connection. This is achieved by supporting virtual
windows inside the screen session. You can
create a new window by pressing The screenshot in Figure 14-8 shows screen with a split window, displaying irssi in a channel where system logs are sent to IRC, and the screen manual page in the bottom half.
If you have played with the split-window feature, you may have
noticed you can have a window visible in several split windows at the
same time. This is actually a very useful feature because
screen allows you to attach to a
screen session more than once. This is called
multiple display mode, and you can use it to display the same window
on multiple terminals, or you can display a different window on
different terminals. To use it, simply add the
screen also has support for copy and paste from
one window to another. Type More relevant to IRC is a script that checks that your IRC client is running so you don't even have to manually restart if it crashes or if the system you're running it on is rebooted. This makes use of the To edit your user's crontab, run this command:
You can then create a new line in your crontab:
This causes the script to be run every five minutes. When it runs, it
checks the output of screen also has a command line as well as key
shortcuts. You can access the command line via If you are paranoid about security, you can password-protect
reattaching to your screen by running the There isn't enough room to cover all of
screen's features here;
however, screen has a very good manual page so
Quick key reference:
To get a quick list of all of
screen's key bindings, press
—David Leadbeater |
|
|
||||||||