Skip to content

Instantly share code, notes, and snippets.

@MateusTymoniuk
Created January 26, 2024 19:31
Show Gist options
  • Save MateusTymoniuk/f750e09cbc3e69e185da6fcec7d6853a to your computer and use it in GitHub Desktop.
Save MateusTymoniuk/f750e09cbc3e69e185da6fcec7d6853a to your computer and use it in GitHub Desktop.
This gist contains a simple script to initialize a session with pre-defined windows on tmux
#!/bin/bash
# Set Session Name
SESSION="Work"
SESSIONEXISTS=$(tmux list-sessions | grep $SESSION)
# Only create tmux session if it doesn't already exist
if [ "$SESSIONEXISTS" = "" ]
then
# Start New Session with our name
tmux new-session -d -s $SESSION
# Name first Pane and start zsh
tmux rename-window -t $SESSION:1 'Main'
tmux send-keys -t 'Main' 'clear' C-m
# Create and setup first pane
tmux new-window -t $SESSION:2 -n 'Second'
tmux send-keys -t 'Second' 'ls -l' C-m
# setup Writing window
tmux new-window -t $SESSION:3 -n 'Third'
tmux send-keys -t 'Third' "nvim" C-m
fi
# Attach Session, on the Main window
# My tmux is configured to start from 1 (default is 0)
tmux attach-session -t $SESSION:1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment