Created
September 9, 2021 19:30
-
-
Save thomasuebel/c3fc700ed518944661ad891fe9f3fa03 to your computer and use it in GitHub Desktop.
Launch into a new or attach to an existing tmux session when connecting 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
# Put into .profile | |
if [ -z "$TMUX" ] && [ -n "$SSH_TTY" ] && [[ $- =~ i ]]; then | |
tmux attach-session -t ssh_tmux || tmux new-session -s ssh_tmux | |
exit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
send the motd after connecting to tmux:
tmux send-keys -t "ssh_tmux:0.0" C-z 'cat /run/motd.dynamic' C-m