Last active
August 29, 2015 14:02
-
-
Save FunTimeCoding/70f32d6d37aac23f0ca1 to your computer and use it in GitHub Desktop.
Simplify start and attach to tmux sessions.
This file contains hidden or 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/bash | |
[ "${TMUX}" = "" ] || exit 0 | |
has_session () { | |
tmux has-session -t $1 2>/dev/null | |
} | |
DEFAULT_NAME="_default" | |
if ! has_session "${DEFAULT_NAME}"; then | |
tmux new-session -s "${DEFAULT_NAME}" -d | |
fi | |
PS3="Select session: " | |
OPTIONS=($(tmux list-sessions -F "#S") "NEW") | |
select OPTION in "${OPTIONS[@]}" | |
do | |
case ${OPTION} in | |
"NEW") | |
read -p "Enter new session name: " SESSION_NAME | |
tmux new-session -s "${SESSION_NAME}" | |
break | |
;; | |
*) | |
tmux attach-session -t "${OPTION}" | |
break | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment