12 Jan 2014 on web and iot

Often we have about 3 to 4 active projects. I am using a simple bash script with tmuxinator to fire up all the related elements of a single project so that it is ready to code in less than 10 seconds.

Let's say we have 3 to 4 active projects at any one time. These projects might include, a couple of client projects, a side project or even a blog. Every time when starting each of these projects, typically the following applications need to be opened:

Text editor with different folder paths

Command line with various panes and tabs

Some native applications

Browser with various tabs

For each of the projects, the exact requirements to the above 4 applications definitely differs. For example, the browser needs to be opened in a different localhost port for different projects along with links to Github or Trello.

For the past few months, I have been automating the opening up of various project related elements with a single command - the project name itself. Here's how the effect looks like when I open up various application with a single command to work on my blog:

With AlfredApp, we can call the shell command without launching any command line application with a simple prefix of >. The bash script that we will create will open up various applications, url and paths in the Finder. Tmux is a terminal multiplexer and I use it more oten to layout the arrangement of windows and panes that are running different commands.

Let's take the example of this blog itself and create the 2 files:

blog (bash script)

blog.yml (tmuxinator project file)

Create the script file

Usually, I just name the file as the project. In this case, it will be simply blog. As this file needs to be an executable, we will also change the file permission with the command chmod. Lastly, we will symlink this file to a file in a directory where all such automated scripts are stored. This directory has to be found in your path variable$PATH. Now, this script can be run from any location.

#!/bin/bash
# USAGE in the command line:
# blog
app="/Users/sayanee/Sites/blog/app" # path to source code
open $app # open in Finder
subl $app # open in text editor
cd _posts && open `ls -tr | tail -1` # open last modified file (latest post)
open /Applications/Tower.app # open version control visualiser
open https://github.com/sayanee/blog/issues/assigned/sayanee?state=open # open git remote repo assigned to me
open http://localhost:4000 # open in development
open http://blog.sayan.ee # open in production
tmuxinator blog # open tmuxinator project

Create the tmuxinator project

Next, we will create the tmuxinator project file that will define the various window, panes and commands to fire when starting the project. Let's first create the file blog.yml and create a symlink to the ~/.tmuxinator folder.

$ touch blog.yml
$ ln -s blog.yml ~/.tmuxinator/blog.yml

In the Tmuxinator project, I will define various windows for the following purpose depending on the project:

And here is the tmuxinator project file todo.yml with 4 windows opening up the development for frontend, backend or api documentation and lastly even the production server. When starting to code, I usually like to do a git pull to sync my code base with the remote repository. Also, when logging into the production server with ssh, I directly cd into the direcotry required.

Fast context switching

One of the challenges of getting into the zone of creativity is how fast and easily we can launch the various applications and commands to get started, especially if we are spending some time launching them often. Here are some other projects that I found that helps in launching current projects fast: