Skip to content

Instantly share code, notes, and snippets.

@James-Firth
Last active January 15, 2024 19:46
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 James-Firth/21a6824cada98985c7d7f6def579cd3b to your computer and use it in GitHub Desktop.
Save James-Firth/21a6824cada98985c7d7f6def579cd3b to your computer and use it in GitHub Desktop.
[Servers] tmux on ssh

On the server, put this snippet in ~/.bashrc to automatically open tmux on ssh

# Open Tmux Session immediately on SSH and exit SSH Session when exiting tmux
if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then
    tmux attach-session -t ssh_tmux || tmux new-session -s ssh_tmux;
    exit;
fi
@James-Firth
Copy link
Author

Combine this with the VS Code Remote-SSH extension for easy VM-based dev

@James-Firth
Copy link
Author

Forget how tmux works? Use this cheatsheet! https://tmuxcheatsheet.com/

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