Skip to content

Instantly share code, notes, and snippets.

@thiemok
Created March 14, 2018 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiemok/4c7e32c2f21609c5d4505e19436541fb to your computer and use it in GitHub Desktop.
Save thiemok/4c7e32c2f21609c5d4505e19436541fb to your computer and use it in GitHub Desktop.
Auto launch tmux, add this to your .bashrc or similar
[[ $- != *i* ]] && return
if [[ -z "$TMUX" ]] ;then
ID="`tmux ls | grep -vm1 attached | cut -d: -f1`" # get the id of a deattached session
if [[ -z "$ID" ]] ;then # if not available create a new one
tmux new-session
else
tmux attach-session -t "$ID" # if available attach to it
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment