Exercise 3: A Reattach-or-Create Shortcut — Possible Solution ============================================================== Add to ~/.bashrc: alias work='screen -d -R -S work' Then reload it: source ~/.bashrc How it behaves: - No "work" session exists -> -R creates a new one named work - "work" exists and is detached -> it is reattached - "work" is attached elsewhere -> -d detaches it from there first, then it is reattached here Why these options: -S work gives the session a fixed name, so the command always finds the same session rather than an arbitrary one. -R reattaches if possible, creating the session otherwise. -d handles the common case where an old connection (for example a laptop that went to sleep) still counts as attached. Using -D instead of -d would also log out the other terminal. That is stronger, and can be useful if you want to be sure the old login is closed, but -d is enough for most people. WHY THIS WORKS AS AN ANSWER ------------------------------ It covers all three starting states (missing, detached, attached elsewhere) and justifies each option, rather than just copying a command.