Created
June 22, 2012 18:39
-
-
Save bmorton/2974447 to your computer and use it in GitHub Desktop.
Tmux Template for Vagrant based workflow
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/sh | |
# | |
# Tmux Template for Vagrant based workflow | |
# | |
# Author: Chris Kempson | |
# Created: 04/03/12 | |
# Updated: 04/03/12 | |
#### CONFIG OPTIONS #### | |
# Name of Tmux Session | |
SESSION="ex" | |
# Project Paths | |
VAGRANT_DIR="/Users/Chris/Developer/Vagrant/server-1" | |
PROJECT_DIR="$VAGRANT_DIR/www/example" | |
PROJECT_URL="http://example.dev:8080" | |
#### END OF CONFIG OPTIONS #### | |
# Create a new tmux session | |
tmux new-session -d -s $SESSION | |
# Set session env vars | |
tmux set-environment -t $SESSION PROJECT_DIR $PROJECT_DIR | |
tmux set-environment -t $SESSION PROJECT_URL $PROJECT_URL | |
# Set default path for new windows | |
tmux set-option -t $SESSION default-path $VAGRANT_DIR > /dev/null 2>&1 | |
# Hack to refresh env vars for initial window | |
tmux new-window -t $SESSION:2 | |
tmux kill-window -t $SESSION:1 | |
tmux new-window -t $SESSION:1 | |
tmux kill-window -t $SESSION:2 | |
# Change the default path for new windows | |
tmux set-option -t $SESSION default-path $PROJECT_DIR > /dev/null 2>&1 | |
# Create new windows | |
tmux new-window -t $SESSION:2 | |
tmux new-window -t $SESSION:3 | |
# Rename windows | |
tmux rename-window -t $SESSION:1 vagrant | |
tmux rename-window -t $SESSION:2 www | |
# Execute window commands | |
tmux send-keys -t $SESSION:3 "cd ~; clear" C-m | |
# Give window 1 focus | |
tmux select-window -t $SESSION:1 | |
# Attach tmux client to the new server session | |
tmux attach -t $SESSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment