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 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 |