Skip to content

Instantly share code, notes, and snippets.

@codekirei
Created June 27, 2014 20:36
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 codekirei/af8310056137203b5e7b to your computer and use it in GitHub Desktop.
Save codekirei/af8310056137203b5e7b to your computer and use it in GitHub Desktop.
A simple shell script that determines if a specific named tmux session exists then attaches to it or creates it.
#!/bin/zsh
grepTest=$(tmux list-sessions | grep $1)
if [ ! $grepTest ]; then
tmux new -s $1
else
tmux attach -t $1
fi
@codekirei
Copy link
Author

For ease of use, I added this script to my $PATH and added the following line to .zshrc:

alias tma='tmux-hybrid-attach.sh $1'

Also, don't forget to make the script executable with chmod +x.

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