Created
January 30, 2024 15:17
-
-
Save theothermattm/e27bb2c11a3b796b70a32d3bdf9a4ed8 to your computer and use it in GitHub Desktop.
Setup predefined TMUX sessions with splits
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/zsh | |
# https://superuser.com/a/440082 | |
SESSIONNAME="number1" | |
tmux has-session -t $SESSIONNAME &> /dev/null | |
if [ $? != 0 ] | |
then | |
tmux new-session -s $SESSIONNAME -n script -d | |
tmux split-window -v -t $SESSIONNAME | |
tmux send-keys -t $SESSIONNAME.1 "cd ~/workspaces/dir1" ENTER | |
tmux send-keys -t $SESSIONNAME.2 "cd ~/workspaces/dir2" ENTER | |
fi | |
SESSIONNAME="number2" | |
tmux has-session -t $SESSIONNAME &> /dev/null | |
if [ $? != 0 ] | |
then | |
tmux new-session -s $SESSIONNAME -n script -d | |
tmux split-window -v -t $SESSIONNAME | |
tmux send-keys -t $SESSIONNAME.1 "cd ~/workspaces/dir3" ENTER | |
fi | |
tmux attach -t $SESSIONNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment