Getting to code in under a minute with Teamocil

Email this to someoneTweet about this on TwitterShare on Reddit0Share on LinkedIn0

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!

Email this to someoneTweet about this on TwitterShare on Reddit0Share on LinkedIn0

One Comment

  • Hi Rob! Well, I can tell you my point of view. The reason I strated looking into this poweruser stuff a while ago was because I had two things in mind:a) Minimise mouse use. I tend to suffer, now and again, of pain in my wrist and forearm, so is essential for me to keep my movements as reduces as possible, focusing them on the keyboardb) Portability. This is the key point here. The idea was to create an environment (e.g. tmux, vim, mutt, etc etc) highly portable across *nix platforms. This way, I though, the way I will need to work on Linux, rather than a Mac (and it happened!) I will have my workflow unaffected! In this outlook, try to think what may happen if you decide to change job and end up in a company which uses only Linux boxes. This way, whilst you can bring ST with you, you can’t use iTerm2 anymore! That was my idea; relying on a subset of highly customisable and portable tools which allow me to be productive since day one in any new environment I have to deal with; I just clone my git repo and I’m ready to go! Does this convince you a little bit more? Anyway the book I mentioned is relatively small but it’s worth its money, I suggest you look at it if you want to improve your tmux experience

    Reply

Submit a Comment