Last active
March 28, 2023 10:55
-
-
Save riscie/47956c7d2c02df01bcfa53d105e7f2a6 to your computer and use it in GitHub Desktop.
automatically start tmux when ssh into a box #zsh #shell
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
I happaned run into the nested tmux case, this may help:
nest tmux in a remote ssh shell