So I’m relatively new to vim (in that I’m using it as my full time editor ), and being that I have a lot of different projects tmux seemed like a natural fit. So, being that I am a part of a lot of different projects I put together this little shell script to manage my tmux sessions, so figured I’d share it here with you guys.
I named the file tm
, made it executable and put it in a bin folder.
#!/bin/sh
export PATH=$PATH:/usr/local/bin
# abort if we're already inside a TMUX session
[ "$TMUX" == "" ] || exit 0
# present menu for user to choose which workspace to open
PS3="Please choose your session: "
options=($(tmux list-sessions -F "#S") "New Session" $(basename "$SHELL" | tr '[:lower:]' '[:upper:]'))
echo "Available sessions"
echo "------------------"
echo " "
select opt in "${options[@]}"
do
case $opt in
"New Session")
read -p "Enter new session name: " SESSION_NAME
tmux new -s "$SESSION_NAME"
break
;;
$(basename "$SHELL" | tr '[:lower:]' '[:upper:]'))
$(basename "$SHELL") --login
break;;
*)
tmux attach-session -t $opt
break
;;
esac
done