Created
December 23, 2015 18:36
-
-
Save JC1738/747c9b58fca794978eaf to your computer and use it in GitHub Desktop.
Add to iTerm2 Profile Start for establishing TMUX session
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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