screen - macOS


Overview

screen is a terminal multiplexer that manages multiple text sessions within a single physical terminal. It allows users to create, detach from, and interact with multiple terminal sessions concurrently, providing an efficient multitasking experience.

Syntax

screen [-options] [command [args]]

Options/Flags

  • -a: Append to an existing session instead of starting a new one.
  • -c: Create a new session.
  • -d: Detach from the current session.
  • -l: List available sessions.
  • -r [session_name]: Resume a session by name.
  • -S [session_name]: Specify a name for the new session.
  • -s: Start a new session with a shell.

Examples

  • Start a new session with a shell:
screen
  • Start a new session with a specific command:
screen -c bash -c 'cd /tmp && ls -l'
  • Resume session named “my_session”:
screen -r my_session
  • Detach from the current session:
screen -d

Common Issues

  • Session not found: Ensure the correct session name is specified when resuming a session.
  • Input not working: Verify that the terminal emulator is properly configured for the screen session.
  • Permission denied when opening a session: Check if the user has sufficient permissions to access the desired session.

Integration

screen can be combined with other commands for advanced tasks:

  • Splitting panes: Use C-a S to create vertical or horizontal splits.
  • Sharing sessions: Allow multiple users to access the same session using screen -x.
  • Window management: Use C-a w to navigate and manage multiple session windows.
  • tmux: Another popular terminal multiplexer with more advanced features.
  • byobu: A lightweight window manager for text-based UIs.
  • tmuxinator: A tool for managing and configuring tmux sessions.