GNU Screen is a terminal multiplexing utility that has the following concrete advantages:

However, text-mode junkie Emacs enthusiasts who would also be GNU screen lovers, may find the biggest stumbling block to the path of enlightenment is the out of the box setting for the Command Key.

Redefining the Command key

Emacs uses ‘C-a’ for ‘beginning-of-line’. It is also the command key for GNU Screen, which causes a problem of “muscle memory impedance matching.”

Suggestions for Command key Redefinition


    ## Control-^ (usually Control-Shift-6) is traditional and the only key not used by emacs
    escape ^^^^
    ## do not trash BackSpace, usually DEL
    bindkey -k kb
    bindkey -d -k kb
    ## do not trash Delete, usually ESC [ 3 ~
    bindkey -k kD
    bindkey -d -k kD

Put the following (for example) into your .screenrc to use `C-\’ as the command key:

    escape ^\\\

But be aware that C-\ sends SIGABRT to the foreground process. I ended up killing many programs because of typos and muscle-memory. (fadein)

Or C-z:

    escape ^Zz

I really like rebinding it to C-o, this way you can flip between split screens quickly C-o C-i (BasKok):

    escape ^Oo

I use C-] (Anonymous):

    escape ^]^]

I like Ctrl-Space. Besides Emacs, I haven’t encountered another program that uses this control character. Moreover, your thumb is always on the spacebar, making this as fast as a home-row escape key (fadein):

    escape ^@@

I (piyo) use C-T because it doesn’t collide with anything else other than M-x transpose-char and your favorite shell’s transpose-char (often used bindkey setting). C-z is too risky because it’s a Unix (suspend-emacs) and Windows (undo) vital key. Though they are all great unique keystrokes, C-] and C-\ and C-o are two-handed and too far away. I suppose C-o is good because it replaces the useless M-x open-line. But still I assert C-T’s dominance (haha). Make sure to bind C-T C-T to self-insert a C-T, so you don’t lose your transpostion-ness muscle memory. Here’s a .screenrc excerpt sample:

  # Define a sane GNU screen command entry character
  # first letter defines the screen command key.
  # second letter defines the literal insert key.
  escape "^T^T"

Is there anyway to use C-; ?? I’ve tried a million combinations including RTFM but can’t seem to get it working (nimms).

Common Usage

Best feature is detach/reattach, e.g.,

    $ screen -D -R

disconnects your old terminal session and reconnects the same session at your new location. Especially great when bad network connections randomly disconnect you, no problem, seamlessly picks up where you were.

Next best feature is sharing, e.g.,


    ## console sharing
    multiuser on
    acladd mypal
    $ screen -x mypal/

be sure you trust ‘em to spy on your screen and type on your keyboard.


Version 4.x seems fine, a bug in prior versions fails to enable sending mouse events, workaround by

    $ ps -auxwww | grep [s]creen
    ... pty/0 ... screen ...
    $ echo -e '\e[?1000h' > /dev/pty/0-or-whatever-tty-screen-is-sending-to

which you’d do at each login - easier to upgrade.

Experimental screen-bce with MacOSX Terminal gets crazy blinking underlined text instead of colors, works fine with MacOSX iTerm. No news yet with MS-Windows PuTTY.

I’m not sure if this is truly a bug, but it is a frustration to which I haven’t found a solution. I’ve found that when pasting text from a Word document or other windows source into emacs -nw running in SecureCRT, that characters such as ‘ and - and bullet characters can have negative interactions with text mode and/or filladapt mode such that instead of getting all of your pasted text, it gets chopped up as though the punctuation and special characters are being interpreted as cursor movement or line deletes, or the like. I can’t say the root cause with any certainty, but I have found that dropping out of screen and running emacs -nw from a plainer terminal seems to not have the problem.

Running Screen Under AnsiTerm

General solution for eterm-color

If you get the message Cannot find terminfo entry for 'eterm-color'. try copying the eterm entry: cp /usr/share/terminfo/e/eterm /usr/share/terminfo/e/eterm-color

If the remote server is SunOS, we might need to put the following



in the remote server’s .bashrc file.

Debian-based solution for eterm-color

If you are in Debian, Ubuntu, Mint, etc. it is possible to install ncurses-term:

sudo aptitude install ncurses-term

Fast connection to a remote shell

In a given Screen or tmux window, if you’ll be connecting to a remote shell, there’s the mosh project [1]. Along with its state synchronisation protocol, it allows for fast local responsiveness, and it supports roaming - making it a great drop-in replacement for ssh (and thus a practical possibility to connect to a remote host over a slow internet connection). Does anyone else think it would be a good idea [2] to implement an Emacs mosh client?

256 Colours under Gnu Screen

Put the following line into your `.screenrc`:

    term screen-256color

You will also need to create a file called `term/screen-256color.el`someplace your load-path can find. Inside the file, put the following code block into it:

    (defun terminal-init-screen ()
      "Terminal initialization function for screen-256color."
      (load "term/xterm")

If the planets have aligned correctly, you should know see colors other than the standard 8/16. You can verify this using `M-x list-colors-display`; if you set things up correctly there should be lots of colors

There is a possibility that your distro might not include any terminfo data for screen-256color by default. On Debian systems, you can install it yourself:

    # aptitude install ncurses-term

If this does not work either, the last resort is to attempt setting using `term xterm-256color` in your `.screenrc`. This should work fine, but is a bodge since the terminal is technically screen itself, not the xterm. If it breaks, you get to keep both pieces.

Thanks to [3] for helping find some correct information.

Multiple EMACS within screen

How do people handle multiple emacs sessions within screen. I often have two or more emacs sessions within screen looking at different files. What method do people use to copy between multiple sessions? Screen’s copy capabilities? Or is there a way to use the kill-ring between emacs sessions? If I use Screen’s copy I cannot scroll through the emacs buffer. If I use the emacs kill-ring I cannot paste on a different emacs session. Does anyone have a solution for this?

 You could use emacs as server : `emacs --daemon` and `emacsclient -t`.

Using Emacsclient with GNU Screen

Using EmacsClient with screen

I use screen all the time, and always wanted to get it to autoswitch back and forth between shell and emacs window. I now figured out how, and here is what I do:

In ~/.screenrc I have:

 screen -t Emacs 1 /usr/bin/emacs

In ~/bin/emacs I have the following:

 echo $WINDOW >~/tmp/emacsclient-caller
 screen -r -X select 1
 emacsclient "$1"

And in my InitFile I have:

    (add-hook 'after-init-hook 'server-start)
    (add-hook 'server-done-hook
              (lambda ()
                 "screen -r -X select $(cat ~/tmp/emacsclient-caller)")))

Now I only need to set my EDITOR environment variable to ~/bin/emacs.


With MultiTTYSupport emacs branch, simply calling emacsclient -t would be enough and would not require such a hack 😊 Plus it is really damn fast ;)


I’ve made a screenserver.el that takes this an extra step, allowing you to move to the correct screen window no matter where you run the emacs server.


I wanted a do-it-all script, that would:

All you need is to drop and chmod u+x the following shell script somewhere in your PATH:

add this snippet to your .emacs:

  ;; emacsclient/server hook
  (defvar server-seb-mode-map
    (let ((map (make-sparse-keymap)))
      (define-key map "\C-xk"
	'(lambda ()
	   (shell-command (concat "touch " "/tmp/blah"))
  (define-minor-mode server-seb-mode "Server")
  (add-hook 'server-visit-hook 'server-seb-mode)

and then add the following into one of your shell startup files:


if you’re used to typing ‘emacs’, maybe also alias it:



Using EmacsClient with Dtach

What is dtach ?

dtach (Emulate GNU screen’s detach feature.)

dtach is a tiny program that emulates the detach feature of GNU screen, allowing you to run a program in an environment that is protected from the controlling terminal and attach to it later.

Visit the dtach homepage project at

Using it

The cool thing with dtach is that you do not have anything to setup, just run something like:

 dtach -A /tmp/emacs emacs

that’s all !

When you want to detach from a running session, just press C-\. To reattach, run your dtach command again. Very simple and very handy.