Skip to content

Instantly share code, notes, and snippets.

@jhirbour
Created January 27, 2017 16:31
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 jhirbour/024d7d4995d52ecde8876f753f100be3 to your computer and use it in GitHub Desktop.
Save jhirbour/024d7d4995d52ecde8876f753f100be3 to your computer and use it in GitHub Desktop.
Create a Named Tmux session, named the same as the directory you're currently in.
#!/bin/sh
#PROJECT_NAME=`basename $PWD`
PROJECT_NAME=`basename $PWD | tr '.' '-'`
PROJECT_DIR=$PWD
tmux has-session -t $PROJECT_NAME 2>/dev/null
if [ "$?" -eq 1 ] ; then
echo "No Session found. Creating and configuring."
pushd $PROJECT_DIR
tmux new-session -d -s $PROJECT_NAME
tmux source-file ~/bin/tmux-${PROJECT_NAME}.conf
popd
else
echo "Session found. Connecting."
fi
tmux attach-session -t $PROJECT_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment