docopt gets CLI argument parsing right

Brilliant ideas can be painfully obvious in retrospect. They’ll leave you thinking, “Why didn’t we I think of that before?!” Docopt is that for parsing CLI arguments.

Thoughtbot brings us rcm for serious rc file management #

If you believe that constantly improving your rc files (dotfiles) is Serious Business™, you gotta check out Thoughtbot’s latest open source project: rcm, an rc file manager

In his introductory blog post, Mike Burns describes rcm as:

a unification of the existing shell scripts, make targets, rake tasks, GNU Bash constructions, and Python hacks that people copy and paste into their dotfiles repo, with a classical unix flair

Unclutter your .profile with direnv #

direnv is a rad looking shell extension that does some of the job of rvm, rbenv, or virtualenv in a language agnostic way.

Instead of putting all of your environment setup in your ~/.profile, direnv lets you use directory-specific .envrc files. Recently rewritten in Go, direnv works with bash, zsh, and fish shells. Check it out.

Deploy apps to your own mini-Heroku with Dokku #

dotCloud’s Docker — a project which makes managing Linux containers easy, previously covered here and discussed on episode #89 — is inspiring & enabling a bunch of open source Platforms as a Service (PaaS).

One of the first (and definitely the smallest) of these is Dokku by Jeff Lindsay.

Dokku weighs in at under 1,000 lines of Bash and offers the same git-push-based app deployment made famous by Heroku and emulated by many PaaS providers. After installation and some configuration, you can deploy to your own mini-Heroku using one of the many supported buildpacks.

Here’s what deploying Heroku’s example Node.js app looks like with Dokku:

$ cd node-js-sample
$ git remote add progrium
$ git push progrium master
Counting objects: 296, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (254/254), done.
Writing objects: 100% (296/296), 193.59 KiB, done.
Total 296 (delta 25), reused 276 (delta 13)
remote: -----> Building node-js-app ...
remote:        Node.js app detected
remote: -----> Resolving engine versions

... blah blah blah ...

remote: -----> Application deployed:

It’s exciting to see how much can be done with so little code. Dokku is MIT licensed and hosted on GitHub.

Multi-user tmux made easy with wemux #

Two of the many things in the development community that are growing in popularity are remote work and pair programming. Traditionally, pairing meant you had two people looking at the same computer and one person doing the typing. This is great, as long as you are in the same room.

What about those developers, like myself, who rarely (if ever) find themselves in the same room as their coworkers? Enter wemux by Matt Furden, the tmux tool that makes it simple for multiple users to connect to the same tmux session so you can see the same thing.

The only requirement, according to the README, is tmux >= 1.6. Installation is simple, with the preferred method being Homebrew:

>> brew install

After installation, you — the host — would start a new wemux server:

>> wemux start

At this time, anyone else — the clients — could connect with any of the following three commands:

  • wemux mirror – attach to the server in read-only mode.
  • wemux pair – attach to the server in pair mode, where both the client and the host can control the terminal.
  • wemux rogue – attach to the server in rogue mode, where the client and host can work independently of eachother.

There are plenty of other features, from listing users to running multiple wemux servers at once. Once you get the hang of it, pairing while working remotely becomes much simpler than screen sharing on Skype!

You can find out everything you need to know in the README or discuss this post on HackerNews.

BDSM: Yes, Bash is a Real Programming Language #

Wayne Seguin is the only Rubyist I know that’s not really known for writing Ruby. When writing RVM, Wayne built it in Bash shell scripts, and as it grew, it got big and unwieldy. Wayne, being the kind of person he is, decided to make Bash more respectable rather than just move to a better language.

Hence BDSM. It stands for “Badass Delectable Scripting Modules”, and that’s what it does: gives you some great tools for writing larger programs in Bash script. The first thing that it’s been applied to has been deployments. You can use BDSM to set up your application’s environment in the same way that you can use RVM to set up your Ruby environment.

Check it out, here’s an example from the RVM deployments page:

appuser$ bdsm bdsmrc      # Put a default ~/.bdsmrc in place.
appuser$ vim ~/.bdsmrc     # Update settings, specifically repository_url, etc...
appuser$ bdsm rails setup # This sets up ~/shared path etc
appuser$ bdsm deploy      # Updates ~/current with a fresh release.
appuser$ vim ~/shared/config/database.yml # setup your db connection info.
appuser$ cd ~/current
appuser$ gem install bundler && bundle install # Be sure that 'gem "unicorn"' is in Gemfile first, no version.
appuser$ bdsm unicorn start
root# bdsm nginx package install
root# chmod go+rx /home/appuser # This makes sure that Nginx can read the dir.
root# bdsm nginx service appuser # This creates /etc/nginx/servers/appuser.conf configured for a unicorn UDS proxy by default.
root# bdsm nginx service start

You can follow along with the comments, but that gets you set up with a system ready to deploy Rails apps. When you have a second app on the same box, you make a new user, and do the first half again.

I’ve done this with two small apps on a VPS, and it’s really awesome. It gives me 90% of the feel of Heroku, but for only $15/month. Heh. Here’s what I did: Since the deployed apps are stored in /home/appuser/current, I make a /home/appuser/code, and that holds the git repo. I set that up as ‘production’ in git, and add a post-commit hook that automatically, runs bdsm deploy && bdsm unicorn restart, and now, ever time I git push production, my site just redeploys. And it’s totally separate from the other app on the server.

Really, all of this is enabled by having these modules provide a common interface to each package. “bdsm unicorn restart” is the same as “bdsm nginx restart”, which makes it really easy to get up and going, start using a different package, etc. It’s all great stuff.

Anyway, this is a tiny little overview of what BDSM can do right now. Wayne’s got big plans for the future, so keep an eye on this cool little project.

[Github] [Website] [README]

bash-it: A community bash framework in the spirit of oh-my-zsh #

Robby Russell’s zsh framework indeed made us say oh-my-zsh!. With over forty themes and a dozen plugins, oh-my-zsh makes it easy to pimp your zsh.

If you’re perfectly happy with bash and things like right side prompts, smart tab completions, and shared session history aren’t your bag, then check out bash-it from Robert Evans. Like oh-my-zsh, bash-it provides a community framework for pimping your shell using themes and plugins.

To install, clone the repo:

git clone

Be sure and backup your current .bash_profile:

cp ~/.bash_profile ~/.bash_profile.bak

… and then start with bash-it’s default profile template.

cp <path/to/cloned/repo>/template/bash_profile.template.bash ~/.bash_profile

Current plugins provide extra goodies for git, rails, and common aliases. Mercurial support is on the way. Got ideas? Well get to forkin’ and send a pull request already.

[Source on GitHub]

resty: Piping hot REST client for bash or zsh #

I love REST APIs, so I’m always looking for new tools for the toolbox. Resty from Micha Niskin caught my eye because it can be loaded into your bash or zsh. To install, just download the script and source it.

$ curl > resty
$ . resty

Now your shell is loaded up with the Resty commands. First, set an API endpoint, like GitHub:

$ resty*

Now we can make any normal GET, POST, PUT, or DELETE as you would expect.

GET /pengwynn.json

For formatted output, pipe it to pretty print:

GET /pengwynn.json | pp

… or save to a file

GET /pengwynn.json > me.json

REST on the Couch

Resty is perfect for CouchDB. Just set your endpoint


… and you’re ready to create datbases

PUT /test '{}'

… and stash documents.

PUT /test/me < me.json


Since Resty sits on top cURL, any additional options after the required path will be passed along to cURL:

GET /repos/show/pengwynn -u pengwynn:0U812

Be sure to check out Jan-Piet Mens’ introductory screencast or the README for advanced usage.

[Source on GitHub] [Screencast]