Skip to content

Instantly share code, notes, and snippets.

@JC1738
Created December 23, 2015 18:36
Show Gist options
  • Save JC1738/747c9b58fca794978eaf to your computer and use it in GitHub Desktop.
Save JC1738/747c9b58fca794978eaf to your computer and use it in GitHub Desktop.
Add to iTerm2 Profile Start for establishing TMUX session
#!/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=($(tmux list-sessions -F "#S") "NEW SESSION" "BASH")
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
;;
"BASH")
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