Skip to content

Instantly share code, notes, and snippets.

@kekneus373
Created January 13, 2026 17:22
Show Gist options
  • Select an option

  • Save kekneus373/5c2a8183b7d53c1e001fd399f02d0dc7 to your computer and use it in GitHub Desktop.

Select an option

Save kekneus373/5c2a8183b7d53c1e001fd399f02d0dc7 to your computer and use it in GitHub Desktop.
tmux and never lose SSH again

To use tmux for a persistent Midnight Commander session that survives SSH disconnections:

Starting a persistent session

  1. SSH into your server and start tmux:

    ssh your-server
    tmux new -s mc
  2. Launch Midnight Commander inside tmux:

    mc

Now your Midnight Commander session runs inside tmux and won't be interrupted if your SSH connection drops[1][3].

Reconnecting after disconnection

When your SSH connection interrupts, simply reconnect and reattach to your tmux session:

ssh your-server
tmux attach -t mc

Your Midnight Commander will be exactly as you left it[1][5].

Key tmux commands

  • Detach manually (leave tmux running): Press Ctrl+b then d
  • List active sessions: tmux list-sessions
  • Kill session when done: tmux kill-session -t mc

The key advantage is that tmux keeps your session alive on the server even when you disconnect, so long-running tasks or file operations in Midnight Commander won't be interrupted[3][5].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment