Skip to content

Instantly share code, notes, and snippets.

@caglar10ur
Last active May 10, 2019 18:36
Show Gist options
  • Save caglar10ur/6348419 to your computer and use it in GitHub Desktop.
Save caglar10ur/6348419 to your computer and use it in GitHub Desktop.
tmux.sh
#!/bin/sh
export PATH=$PATH:/usr/local/bin
# abort if we're already inside a TMUX session
[ "$TMUX" == "" ] || exit 0
# startup a "default" session if none currently exists
tmux has-session -t DEFAULT || tmux new-session -s DEFAULT -d
# present menu for user to choose which workspace to open
PS3="Please choose your session: "
options=("NEW SESSION" "REGULAR CONSOLE" $(tmux list-sessions -F "#S"))
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
;;
"REGULAR CONSOLE")
bash --login
break;;
*)
tmux attach-session -t $opt
break
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment