bin/tm
#!/bin/bash
if [ "$TMUX" != "" ] ; then
echo "Abort: Already in a tmux session."
exit 0
fi
options=($(tmux list-sessions -F "#S" 2>/dev/null) "New session")
PS3="Please choose your session: "
select opt in "${options[@]}"
do
case "$opt" in
"New session")
read -r -p "Enter new session name: " SESSION_NAME
tmux new -s "$SESSION_NAME"
break;;
*)
tmux attach-session -d -t "$opt"
break;;
esac
done