Skip to content

Instantly share code, notes, and snippets.

View TechnologyClassroom's full-sized avatar
💭
Hacking

Michael McMahon TechnologyClassroom

💭
Hacking
View GitHub Profile
@TechnologyClassroom
TechnologyClassroom / auto-start-tmux-ssh.txt
Last active March 12, 2023 22:24 — forked from ThomasLeister/auto-start-tmux-ssh.txt
Put this into your .bashrc to auto-start a tmux session after SSH login
# Put these lines into your server's .bashrc:
##
## TMUX auto attach
##
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then # If this is an SSH session
if which tmux >/dev/null 2>&1; then # Check if tmux is installed
if [[ -z "$TMUX" ]] ;then # Do not allow "tmux in tmux"
ID="$( tmux ls | cut -d: -f1 | head -n 1 )" # Get the id of an existing session
if [[ -z "$ID" ]] ;then # If not available create a new one
tmux new-session