Skip to content

Instantly share code, notes, and snippets.

@binarymatt
Last active July 2, 2023 04:33
Show Gist options
  • Save binarymatt/b0a8f278d6969618f2b6e5ab309a15ef to your computer and use it in GitHub Desktop.
Save binarymatt/b0a8f278d6969618f2b6e5ab309a15ef to your computer and use it in GitHub Desktop.
#!/bin/bash
function tmux_create {
SESSION_NAME=$1
tmux new -s $SESSION_NAME -n neovim
}
#new session base name is current directory name
DIR_NAME=${PWD##*/}
DIR_NAME=${DIR_NAME//./_}
echo "checking for tmux session with name '$DIR_NAME'."
tmux has -t $DIR_NAME 2> /dev/null
retVal=$?
if [ $retVal -ne 0 ]
then
echo "Session not found. Create Session '$DIR_NAME'."
tmux_create $DIR_NAME
else
echo "attaching to session '$DIR_NAME'"
tmux a -t $DIR_NAME
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment