Using tmux and tmuxinator to organise projects

If you’re anything like me and have a problem with names - not just people - but projects too. Or if you find yourself losing track of projects because of different languages or editors used.

You may find your saviour in the tmux + tmuxinator combo.

When discovering virtualenvwrappers workon command for managing Python projects I was immediately envious of it’s functionality; wishing it was available for other projects.

I wanted a similar app that could launch prepared editor environments. While being flexible enough to change editor on a whim. I often switch between Vim, Sublime and Atom depending on mood and weather. If I’m feeling especially masochistic I’ll setup a project in PHPStorm (leave hate mail below).

Next, something that could store my code locations as I had several. Including ~/Dev ~/Development ~/Sites - don’t ask me why. But also remote locations accessible only via FTP, SSH or some other arcane method.

Now with anything from 2 big to 20 small projects on the go for work and around 20-30 small home/hobby projects its not suprising I got muddled.

In my idle wandering I came across the aforementioned tmuxinator which ticked ALL the boxes using a tool I already used (tmux).

tmux

tumx is like Screen but 10x better. If you’re still using Screen then switch to tmux. If you’ve never heard of Screen then…pretend I said nothing and use tmux!

tmux enables you to save multiple virtual consoles. In a basic way it can help you save your place in an terminal session. This is great for unstable SSH connections. If the session dies then normally you lose everything including spawned processes, etc.

But if you were in a tmux session then its all saved as ts all executed from the tmux process. tmux becomes more profound as you use it. When you combine it with Tmuxinator you suddenly realise you are capable of taking over the universe (or something similar)

Tmuxinator

Tmuxinator gives you all the power of Tmux but with configurable states. So you’re no longer restricted to just saving your last state said but you can set up your own states. Your terminal, and to an extent your system, can be setup for a particular project.

tmux and tmuxinator gives unlimited power

Put another way it gives you that workon used in Python I mentioned earlier with unlimited power.

Imagine you have my hobby project-nest and you are wondering what to do today with your 30+ hobby projects. Do you want to spend 10, 20, 30, 60, minutes hunting for the one you last worked on about 6 months ago whose name began with p?

Oh god you’re sure it was in that folder with other Node experiments maybe or?

You don’t have to remember once you’ve set up a tmuxinator config file in YAML.

All it takes then is:

1
2
3
4
% mux list

tmuxinator projects:
awin-feeder fspart myblog ukp

And all it takes is mux open myblog to open up that project.

Here’s an example of the tmuxinator project file for this blog:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
name: myblog
root: /Users/doug/Sites/dougbromley/blog

windows:
- editor:
layout: main-vertical
panes:
- subl --project myblog.subliime-project; clear
- hexo --help
- genwatcher:
layout: main-vertical
panes:
- hexo generate -w
- hexo serve
- gitstats:
layout: main-horizontal
panes:
- git ll
- git cal
- git summary

In the above its:

  1. Opening the a basic vertical layout
  2. Then in the main pane its opening Sublime with my blog as the main project so I can start editing straight away.
  3. In a separate pane the hexo help command is run to remind me of hexo’s commands.
  4. In another window the hexo local server is run.
  5. In that same window another pane with hexo generate is run with the watch flag so I can see changes regenerated live.
  6. In the final window is a set of panes giving some git info - I often find this useful to remind me where I left the project.
Session Screenshot of Window gitstats

In the past all of these sequences and processes would have to be remembered but if you have multiple projects it can become a burden to remember them all.

Tmuxinator along with tumx makes things much simpler.

No Need to Download Sysinternals Tools

If you’re a Windows user then you’ve likely come across Sysinternals at some point during your time. Although a lot of people may know of it not everyone uses it to its maximum potential.

If you’ve ever been in a position with a unexplainable BSOD, unhelpful error dialogs, then check out Mark Russinovich’s “The Case of the Unexplained” webcasts where he’ll give tips on figuring out what dialogs like these actually mean:

Outlook Express Dialog

Anyway you don’t actually need to download the tools as they have been made available as a share at \\live.sysinternals.com\Tools\

So you can add them as a network drive for easy access

Are Older Programmers Still Viable?

Found this interesting video on whether older programmers can still be relevant. A good question considering I’m now in my thirties and Mark Zuckerberg famously said:

“If you’re over 30, you’re a slow old man” ~ Mark Zuckerberg

(at the time of writing Mark Zuckerberg is 32yrs old - the same age as me)

Along with a string of other similar statements from Zuck and major people at Intel, etc.

I wonder if Zuckerberg’s opinion has changed since he reached 30?

Anyway on to the video which I think hits the nail on the head:

tldw; Basically if you don’t keep up with the trends you will become a dinosaur. But that goes for everyone in every industry.

Thankfully I’m pretty comfortable embracing new technologies! In fact I’m obsessed with checking out new tech and that obsession doesn’t seem to be abating anytime soon.

Hexo and Other Static Site Generators on Reddit

If you’re interested about jumping on the growing static site generator ecosystem and your a Reddit user be sure to check out these Subs for your favourite static site generator:

There’s also a main directory for all these subs being maintained at: /r/staticgen

Check them out, contribute, find your favourite, get involved!

PHP is an Auto-Tri-MountainBike-Car

This is a rewrite of an old joke regarding PHP I did a while back. PHP has come a long way since but I think my description still stands today. I got the original idea after reading this: **If Programming Languages Were Cars.

Here’s my take on PHP as a ‘car’:

PHP Logo

PHP was a mountian bike that got crow barred into a tricycle. Its had a lawn mower engine strapped to its rear wheels and a turbo made from washing machine ducting kitted round the front. To keep it all going a set of stabilisers and prayer beads have been chucked on. The only thing that rea;lly makes it a car is that in most countries it needs a license to drive legally on the roads.

Attempts have been made to re-invent the death trap such as HHVM and PHP7 but its still the same old mess under i all - *does that method have an underscore in it again? Is it haystack needle or vice versa? Oh god - check the manual we may need to jumpstart it!

PHP will get you from A to B but its not as reliable or friendly as that Python and Ruby model that just hovered past.