Skip to content

Instantly share code, notes, and snippets.

@pope
Created March 17, 2014 17:33
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 pope/9604212 to your computer and use it in GitHub Desktop.
Save pope/9604212 to your computer and use it in GitHub Desktop.
#!/bin/bash
declare -r SESSION_NAME=work
# If we don't have a session, then create one with the default windows.
if ! tmux has-session -t $SESSION_NAME 2>/dev/null; then
# Create a new session with the first window named "emacs". Immediately detach.
tmux new-session -d -n emacs -s $SESSION_NAME
# Create a new window named dev. Repeat this for as many new windows you like.
tmux new-window -n dev -t $SESSION_NAME
# Start emacs in the emacs window.
tmux send-keys -t $SESSION_NAME:emacs '$EDITOR -nw'
# Go to the the code directory in the dev window.
tmux send-keys -t $SESSION_NAME:dev 'cd ~/code' C-m
# Select emacs so that we start here.
tmux select-window -t $SESSION_NAME:emacs
fi
# Attach tmux while detaching any existing clients.
tmux -2 -u attach -d -t $SESSION_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment