Lately I’ve found that the overhead of configuring my development environment occupies too much of my development time, particularly on side-projects that are already time-starved. Nobody likes to sit down–all stoked to code–and spend the first 15 minutes just getting everything up and running. Lucky for me, my beautiful and talented co-worker spammed me a helpful link this week for a tmux tool called Teamocil, which it turns out, is kind of the shit. I already use tmux for programming on remote servers to avoid my code disappearing into space in the event that I’m prematurely disconnected, so getting Teamocil up and running was really easy. It’s just a matter of configuring a yaml file.
So here’s my environment for cellbot, a RESTful service that exposes SBML models as JSON (coming soon!). At the moment, I have two basic configurations. The first is my API development set-up which consists of three panes, one large pane for vim and two small ones for the command line/git and my web server.
name: "cellbot-api" windows: - name: "server" root: "~/projects/human-cellbot-api/api" layout: main-vertical panes: - commands: - vim "app.js" - focus: true - commands: - git status - commands: - npm start
Then it’s just a matter of opening a new tmux session and typing “teamocil cellbot”. Teamocil then renames my tmux session to ‘cellbot-api’, constructs my panes, and issues my commands. Ultimately my set-up looks like this:
I have app.js and API documentation open in a split-window vim session (although I did the vim split manually). This makes it super simple to modify the code and documentation (iodocs, thanks Mashery!) simultaneously. Next to that I have an open terminal window for git and any other command line stuff I might want to do. Finally in the bottom left I can monitor my server. Fun!
Second, I have an configuration to fire up my databases. Data for the API are stored in mongodb and I’m using Redis for my OAuth store.
name: "cellbot-db" windows: - name: "db" root: "~/projects/human-cellbot-api/api" layout: main-vertical panes: - commands: - sudo mongod - commands: - sudo redis-server - commands: - sudo mongo - focus: true
In this case I just want to run both of those database servers, and then open a mongo shell so that I can interactively debug my endpoints when I need to. The only minor annoyance is the sudo-ing, but it’s still faster than remembering to start those servers when I have 15 minutes and just want to write code. I also found this post useful, especially the tips about adding mouse actions to tmux, because that’s what enables you to slide the pane sizes around.
I spent some time a few months ago organizing my dotfiles and getting them all up on github and I love that I can include the .teamocil directory in my dotfiles repo and take my environment with me wherever I go. Get into it!