Skip to content

Instantly share code, notes, and snippets.

@paridin
Last active September 21, 2016 15:33
Show Gist options
  • Save paridin/f957ca3cc6164fbb7142c102a3f964a0 to your computer and use it in GitHub Desktop.
Save paridin/f957ca3cc6164fbb7142c102a3f964a0 to your computer and use it in GitHub Desktop.
If you want your tmux was keep on auto start, this snippet is your solution.

How it works

Validate if tmux exists and send the buffer to an empty stream /dev/null -> which tmux 2>&1 >/dev/null If session hack exists it recover it -> tmux attach -t hack Otherwise, It create a new session call hack -> tmux new -s hack

if which tmux 2>&1 >/dev/null; then
  if [ $TERM != "screen-256color" ] && [  $TERM != "screen" ]; then
    tmux attach -t hack || tmux new -s hack; exit
  fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment