Skip to content

Instantly share code, notes, and snippets.

@rstacruz
Last active September 12, 2022 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rstacruz/42c45afa4c34175166f22c20ba9f6714 to your computer and use it in GitHub Desktop.
Save rstacruz/42c45afa4c34175166f22c20ba9f6714 to your computer and use it in GitHub Desktop.

Auto-start Tmux on SSH connection

A one-liner to connect to a server (eg, user@example.com):

ssh -o "RequestTTY force" user@example.com -- tmux new -A -s default

Explanation:

  • -o "RequestTTY force" will prevent the "not a terminal" error when running tmux tmis way
  • -- separates arguments for SSH and arguments to be passed as the initial comamnd
  • tmux new -A -s default will attach to a running "default" session, or start it if it's not running yet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment