Skip to content

Instantly share code, notes, and snippets.

@thomasuebel
Created September 9, 2021 19:30
Show Gist options
  • Save thomasuebel/c3fc700ed518944661ad891fe9f3fa03 to your computer and use it in GitHub Desktop.
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
# 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
@thomasuebel
Copy link
Author

send the motd after connecting to tmux:
tmux send-keys -t "ssh_tmux:0.0" C-z 'cat /run/motd.dynamic' C-m

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