# redefine the tmux cmd to always prompt and re-attach to an old session,
# if no explicit session name given
tmux() {
# if no arguments then check if there is any old sessions
if [ $# -eq 0 ]; then
t=$(which tmux)
results=$($t list-sessions 2> /dev/null)
if [[ -z $results ]]; then
# start normal as the first session
$t
else
# start by attaching to a past session
echo $results | sed -e 's/\] /]\'$'\n/g'
read -p "Which session to attach? " input
$t attach -t $input
fi
else
# call normal with arguments that were passed
$t $@
fi
}
Created
November 29, 2013 22:17
-
-
Save glennschler/7712715 to your computer and use it in GitHub Desktop.
tmux
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment