Skip to content
shellmap

screenDetachable terminal multiplexer — sessions survive disconnects across all 5 shells

Equivalents in every shell

Bashunix
screen -S work

`-S NAME` creates a NAMED session. Detach with `Ctrl-A d`; reattach with `screen -r work`. List sessions: `screen -ls`. The modern preferred alternative is `tmux`, which has better defaults, mouse support, and richer status bars — but `screen` remains pre-installed on more legacy systems.

Zshunix
screen -S work

Same external `/usr/bin/screen`. macOS ships an OLD GNU screen (4.00.x) by default — `brew install screen` for a modern build. Prefix key is `Ctrl-A` by default (collides with bash's start-of-line); rebind in `~/.screenrc` with `escape ^Bb` to free `Ctrl-A`.

Fishunix
screen -S work

Same external. Inside a fish session inside a screen window, scrollback uses `Ctrl-A [` to enter copy mode (then arrow keys + Enter to start/end selection). Screen also lets multiple users attach to the SAME session with `screen -x` — useful for pair-debugging.

PowerShellwindows
Start-Job { long-cmd }

No real `screen` equivalent on Windows. `Start-Job` runs a script block as a background job in the same pwsh session — `Get-Job`, `Receive-Job`, `Stop-Job` manage it. For a true detachable session, use Windows Terminal's tab persistence + a tmux/screen session inside WSL, or PSReadLine + `Start-Process` for separate processes.

cmd.exewindows
# No native equivalent. Use Windows Terminal tabs + WSL screen/tmux.

cmd has no concept of multiplexed sessions. For "long-running task with detach" on Windows, the closest is a Task Scheduler entry or a Windows Service. For interactive multiplexing, use Windows Terminal (`wt.exe`) tabs and run `screen` or `tmux` inside WSL.

Worked examples

Start a named session and detach from it

Bash
screen -S deploy   # then Ctrl-A d to detach
Zsh
screen -S deploy   # then Ctrl-A d to detach

Reattach to a detached session

Bash
screen -r deploy
Fish
screen -r deploy

List active screen sessions

Bash
screen -ls
Zsh
screen -ls

Gotchas

  • Screen's default prefix `Ctrl-A` collides with bash/zsh/readline's `Ctrl-A` (move to start of line). Either rebind in `~/.screenrc` (`escape ^Bb` makes the prefix `Ctrl-B`, same as tmux) or memorize the double-tap idiom `Ctrl-A a` to send a literal `Ctrl-A` to the inner shell.
  • `screen -ls` may list DEAD sessions as `(Dead ???)` — clean them up with `screen -wipe`. Common cause: kernel SIGKILL of the screen process leaves the socket behind in `/var/run/screen/S-$USER/`.
  • macOS's pre-installed `screen` (4.00.x) is YEARS OLD and is missing the `-Logfile` option, the `multiuser on` directive, and modern UTF-8 handling. Always `brew install screen` for a current build (5.x as of recent Homebrew).
  • Screen's multi-user mode (`multiuser on` + `acladd USER`) is powerful for pair-debugging but is a security trap: any user in the ACL can run arbitrary commands as YOU. Audit `screen -x` access on shared hosts; tmux's `-S socket` + group permissions is the more controllable alternative.
  • Windows has no equivalent inside the cmd or PowerShell process tree. The pragmatic Windows answer is "Windows Terminal tabs" for layout + "WSL with tmux" for detach/reattach. Native `Start-Job` and `Start-Process` give you SOME features but not session-resume-after-logoff.

WSL & PowerShell Core notes

pwshOn Linux/macOS pwsh, the external `screen` binary works exactly as in any other shell — pwsh's `&` call operator forwards to it. On Windows pwsh, `screen` is not available; install via WSL or use tmux-on-WSL through `wsl tmux ...`. `Start-Job` is a single-command background runner, NOT a session-resume tool — different abstraction.
WSLRunning `screen` inside WSL2 is the most common "screen on Windows" pattern. Caveat: WSL2 by default shuts down its VM after 8 seconds of idle (no attached WSL processes). To keep your screen session alive after the last WSL terminal closes, run a sentinel — `wsl -d Ubuntu sleep infinity` from Windows Task Scheduler at logon, or set `[wsl2] kernelTimeout=0` in `~/.wslconfig` (not officially supported).

Related commands