The default Screen command character is Ctrl-a, which collides with shells and editors that use Ctrl-a to move to the start of a line. Moving Screen commands to Ctrl-b keeps the session controls available while leaving Ctrl-a for the program running inside the window.

Screen stores the prefix as a two-character escape pair. In escape ^Bb, ^B starts a Screen command sequence, and b is the key typed after the prefix when the running program needs a literal Ctrl-b.

Test the change in one named session before relying on it in daily work. A temporary proof binding can change the window title, so the parent shell can query a clear result before the proof binding is removed from ~/.screenrc.

Steps to change the Screen prefix key:

  1. Start a named test session when no safe Screen session is already running.
    $ screen -dmS work

    The later examples target work. Use a disposable session first if the current Screen session is carrying important work.

  2. Confirm the target Screen session name.
    $ screen -ls
    There is a screen on:
            12345.work      (Detached)
    1 Socket in /run/screen/S-user.

    The -S work examples target the session named work. Use the name shown by screen -ls when your session uses a different name.

  3. Open the Screen config file used by that session.
    $ vi ~/.screenrc

    Most personal sessions read ~/.screenrc unless $SCREENRC or screen -c points to a different file.

  4. Add the new prefix and a temporary proof binding.
    escape ^Bb
    bind Y title prefix-ready

    Use caret notation such as ^B in Screen config files. The bind Y line gives Ctrl-b Y a visible test action and should be removed after verification.

  5. Reload the config into the running test session.
    $ screen -S work -X source ~/.screenrc

    The -X source command asks the named session to read the updated screenrc file.

  6. Attach to the test session.
    $ screen -r work
  7. Press the new prefix and the proof key.
    Ctrl-b Y

    If Ctrl-b is active as the command character, Y runs the temporary title prefix-ready binding.

  8. Detach from the session with the new prefix.
    Ctrl-b d
  9. Query the window title from the parent shell.
    $ screen -S work -Q title
    prefix-ready

    The prefix-ready title confirms that the running session accepted Ctrl-b as the Screen command character.

  10. Remove the temporary proof binding from ~/.screenrc.
    escape ^Bb

    Keep the escape ^Bb line and delete bind Y title prefix-ready unless that binding is also wanted for normal use.

  11. Reload the cleaned config into the running session.
    $ screen -S work -X source ~/.screenrc
  12. Send a literal Ctrl-b to the program inside the Screen window when needed.
    Ctrl-b b

    The second character in escape ^Bb is b, so Ctrl-b b passes Ctrl-b through to the current window.

  13. Start a one-off session with the same prefix when testing before editing ~/.screenrc.
    $ screen -e^Bb -S test-prefix

    The -e^Bb option sets the command characters for that Screen invocation without changing the config file.