Last active
January 3, 2024 02:08
-
-
Save logicalgroove/efe4fa1e6a46c9952a13c637d60028fe to your computer and use it in GitHub Desktop.
Tmux sessions helper
This file contains 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
# setup_tmux_session.sh | |
# chmod +x setup_tmux_session.sh | |
# Usage: ./setup_tmux_session.sh SESSION_NAME FOLDER_PATH | |
SESSION_NAME=$1 | |
FOLDER_PATH=$2 | |
# Check if the session exists | |
tmux has-session -t "$SESSION_NAME" 2>/dev/null | |
# If the session exists, attach to it | |
if [ $? -eq 0 ]; then | |
tmux attach -t "$SESSION_NAME" | |
else | |
# Create the session if it doesn't exist | |
tmux new-session -d -s "$SESSION_NAME" -n 'vim' -c "$FOLDER_PATH" | |
tmux send-keys -t "$SESSION_NAME" 'vim Gemfile' Enter | |
# Create additional windows | |
tmux new-window -t "$SESSION_NAME:" -n 'git' -c "$FOLDER_PATH" | |
tmux new-window -t "$SESSION_NAME:" -n 'server' -c "$FOLDER_PATH" | |
tmux new-window -t "$SESSION_NAME:" -n 'console' -c "$FOLDER_PATH" | |
tmux new-window -t "$SESSION_NAME:" -n 'tests' -c "$FOLDER_PATH" | |
# Select the initial window | |
tmux select-window -t "$SESSION_NAME:vim" | |
fi |
This file contains 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 | |
/Users/youruser/.config/tmux/tmux-sessions/setup_tmux_session.sh "someproject" "/path/to/someproject" |
This file contains 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
alias tmuxsomeproject='. /Users/youruser/.config/tmux/tmux-sessions/tmuxsomeproject.json' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment