Created
April 5, 2019 22:36
-
-
Save jpmens/b3d976bc9e3449f3310f379f0d1c5583 to your computer and use it in GitHub Desktop.
tmux autostart via ssh
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
# .profile | |
... | |
# try to attach to tmux session or create a new one. When | |
# tmux exits (e.g. detach) we exit this session. | |
sname="t-$(hostname)" | |
if [[ -z "$TMUX" ]] && [ "$SSH_CONNECTION" != "" ]; then | |
tmux attach-session -t $sname || tmux new-session -s $sname | |
exit | |
fi |
Note that line 11 can be simplified using the -A
flag for for new-session
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Via Ali we see a method to use for screen(1)