Last active
January 4, 2024 09:04
-
-
Save mahasak/60d89128d65f9e57eabdd4847a63cae9 to your computer and use it in GitHub Desktop.
Reattach to tmux over ssh connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inside your .bashrc or .zshrc (on the server side) add: | |
# start tmux if we ssh into the box | |
if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then | |
tmux attach-session -t $USER || tmux new-session -s $USER | |
fi | |
# this will attach to an ongoing tmux session or start a new one | |
# the session name will be the name of the user ($USER) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment