You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dotfiles/bin/startup/tmux_start.sh

37 lines
898 B
Bash

#!/usr/bin/env bash
SESSION="doormat" # welcom session name
START_SERVER=false
set_session() {
# sets $SESSION variable to doormat
active_sessions=$(tmux list-sessions 2>/dev/null)
if [[ ! -z "$active_sessions" ]] ; then
# active sessions
session=$(echo "$active_sessions" | grep "$SESSION" | cut -d ':' -f 1 2>/dev/null)
# tmux doormat script
if [[ "$session" != "$SESSION" ]] ; then
# door mat doesn't exist
START_SERVER=true
fi
else
START_SERVER=true
fi
if $START_SERVER ; then
# need to start server
tmux new-session -d -s "$SESSION"
tmux set-hook -t "$SESSION" client-attached 'run-shell ~/.dotfiles/bin/startup/lay_doormat.sh'
fi
}
set_session
while getopts "s" arg; do
case $arg in
s)
echo "SESSION=$SESSION"
;;
esac
done