Skip to content

Instantly share code, notes, and snippets.

@flrichar
Last active January 16, 2024 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flrichar/bfe95d130d980b9f279dd9d8ed388ed6 to your computer and use it in GitHub Desktop.
Save flrichar/bfe95d130d980b9f279dd9d8ed388ed6 to your computer and use it in GitHub Desktop.
screen sessions in tmux groups
#!/bin/bash
if $(tmux has-session); then
echo "Tmux has-sessions, exiting..."; exit
else
echo "Tmux no sessions, creating..."
fi
SCREENWIN=$(printf 'C-a c %0.s' {1..5})
TSESSION="tmux"
tmux new-session -s $TSESSION -d -n local
tmux split-window -h -t $TSESSION:0
tmux split-window -v -t $TSESSION:0
## screen-func
##tmux send-keys -t $TSESSION:0.0 'screen -S one' C-m $SCREENWIN
##tmux send-keys -t $TSESSION:0.1 'screen -S two' C-m $SCREENWIN
tmux new-window -t $TSESSION -n infra
tmux send-keys -t $TSESSION:1 'screen -S ONE' C-m $SCREENWIN
tmux split-window -v -t $TSESSION:1
## horiz & vert split
#tmux split-window -h -t $TSESSION:1
#tmux split-window -v -t $TSESSION:1.0
## screen-func (extra screen sessions in tmux panels)
##tmux send-keys -t $TSESSION:1.0 'screen -S three' C-m $SCREENWIN
##tmux send-keys -t $TSESSION:1.1 'screen -S four' C-m $SCREENWIN
tmux select-window -t $TSESSION:0
tmux select-pane -t 0
echo "...done."
###
## modified to check for the session, eliminate some unnecessary screen sessions
## called from a taskfile as a function, also more verbose output for the user
@flrichar
Copy link
Author

Updated this in January 2024...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment