giant robots smashing into other giant robots

Written by thoughtbot

cpytel

How To Use Arguments In a Rake Task

I came across this today. You can write Rake tasks that accept arguments, called like this:

rake tweets:send[cpytel]

You define the rask task like this:

namespace :tweets do
  desc 'Send some tweets to a user'
  task :send, [:username] => [:environment] do |t, args|
    Tweet.send(args[:username])
  end
end

Unfortunately, zsh can’t parse the call to the rake task correctly, so you’ll see the error:

zsh: no matches found: tweets:send[cpytel]

So you’ll need to run it like this:

rake tweets:send\[cpytel\]

Or this:

rake 'tweets:send[cpytel]'

gabebw

Bracket Expansion

Let’s say you want to update capybara and capybara-webkit. You’d normally type this:

gem update capybara capybara-webkit

But you’re busy, you don’t have time to type “capybara” twice. Let’s see what tab completion has for us:

gem update capybara{,-webkit}

The bracket expression expands to the same thing as above because the brackets expand to "capybara" + "" and "capybara" + "-webkit". If you’re in ZSH, you can press the TAB key (gem update capybara{,-webkit}<TAB>) and it will expand the expression for you inline. Bash users, this will still work for you, even without the neat TAB trick.

gabebw

cd’ing to frequently-used directories in ZSH

Josh just dropped some sweet, sweet ZSH knowledge. I spend a lot of time in the directories under $HOME/thoughtbot/ and $HOME/src, and to get there I type (for example) cd ~/thoughtbot/hoptoad. There is a better way!

First, add this to your ~/.zshrc and source it:

setopt auto_cd
cdpath=($HOME/thoughtbot $HOME/src)

Obviously, use different paths in cdpath depending on which directories you cd into a lot.

Now let’s try it out:


$ cd rspec-core # Autocompleted from rspe<TAB>
$ pwd
/Users/gabe/src/rspec-core
$ cd hoptoad
$ pwd
/Users/gabe/thoughtbot/hoptoad

Seriously, check out your coworkers’ dotfiles. It can improve your workflow efficiency by an order of magnitude. Like most of the Thoughtbot crew, Josh keeps his dotfiles on Github.

qrush

Font Battle 2011

A recent straw poll of text editor fonts at thoughtbot found these results. Not all thoughtbot precincts have reported in. Perhaps you’d like to explore some new font options for those walls of text you stare at for 8+ hours daily.

Some links to these fonts:

dancroak

Keeping a GitHub fork updated

I forked a GitHub repo thoughtbot/dotfiles to croaky/dotfiles and want to keep the fork updated.

Track

After I forked the repo to your Github account, I did this one time:

git clone git@github.com:croaky/dotfiles.git
cd dotfiles
git remote add upstream git@github.com:thoughtbot/dotfiles.git

Update

Each time I want to update, from my local master branch:

git fetch upstream
git rebase upstream/master

The goal of the rebase is to have a cleaner history if I have local changes or commits on the repo. It’s the difference between the the left and the right in the image below.

image

Commit rights upstream?

If I also have commit rights to the upstream repo, I can create a local upstream branch and do work that will go upstream there.

git checkout -b upstream upstream/master

Written by .