Because I hate repeating myself, my team and I have gone to great lengths to make our lives easier in our development environments.
On a recent project, we’ve got a lot of things that we need to make sure that our dev environment functions properly (rails, redis, etc). Rather than set all these things up each time we boot up, we’ve got a few conventions that make us _much_ happier.
We give ourselves an alias named current that takes us to that project’s root directory.
# .bash_profile export PROJECT_NAME=my-fancy-repo-dir export PROJECT_ROOT=$HOME/workspace/$PROJECT_NAME alias current='cd $PROJECT_ROOT'
In our project root, we’ve got a file named commands included in our VCS. These commands can be anything from a redis start-up script with config options to a command that runs `rails s` for us. Anytime a new terminal opens up (should be fairly regular), these get refreshed, and changes take effect.
# $PROJECT_ROOT/commands alias server='bin/rails s' alias start_redis='redis-server -blah blah blah' alias start_faye='REDIS_URL=redis://localhost:6379 rackup bin/faye.ru'
# .bash_profile if [ -f "$PROJECT_ROOT/commands" ]; then . "$PROJECT_ROOT/commands" fi
3) A startup script.
Since we’re all on Macs, we wrote some AppleScript that sets up iTerm with all the things we need.
# $PROJECT_ROOT/bin/setup_term osascript <<EOD tell application "iTerm" activate set myterm to (make new terminal) tell myterm set redis_session to (make new session at the end of sessions) tell redis_session exec command "/bin/bash -l" set name to "Redis" write text "current && start_redis" end tell set server_session to (make new session at the end of sessions) tell server_session exec command "/bin/bash -l" set name to "Server" write text "current && server" end tell set faye_session to (make new session at the end of sessions) tell faye_session exec command "/bin/bash -l" set name to "Faye" write text "current && start_faye" end tell end tell EOD
With all of these, this is how I start my machine in the morning.
# Open iTerm
current && bin/setup_osx_term
Got any ideas on how to make this even better? Feel free to throw some comments down below.
About the AuthorMore Content by TJ Taylor