Writing

I should do it more

One-shot command to create a Github pull-request and open it in your browser

At Firmafon we almost always concentrate updates into Github’s pull reqeusts. This provides a nice overview of the changes and an obvious place to discuss them. Here’s two scripts that I use to make this process even easier.

The first one’s called last_commit_message:

#!/bin/sh
git --no-pager log -1 --pretty=%B | sed -e "s/^ *//g" -e "s/ *$//g" | tr -d "\n"

This outputs the last commit’s message, inline without anything else but the message.

The other is called prl:

#!/bin/sh -x
set -e

last_msg="`last_commit_message`"
git push -u
url=`hub pull-request "$last_msg"`
open "$url"

This get’s the last commit’s message for use as the pull request’s title. Then it pushes to a remote branch.

Then using Github’s hub command (brew install hub) it creates a pull request from the current HEAD, catches the returned url and open’s it.

Copy the URL of the current page and return - using Drafts for iOS and this bookmarklet

When I’ve read something and want to link to it or send it to a friend I need to grab the URL from Safari. This consists of tapping the minimized address bar, then tap the address bar, then tap a million times to make the Copy/Paste popup show, then copy. This is not easy.

With this bookmarklet in your Favorites folder, it’s as easy as tap, tap, tap and you’re done.

var a=encodeURI(window.location.href);window.location='drafts://x-callback-url/create?text='+a+'&action=Copy%20to%20Clipboard&x-success='+a;

Drafts opens up, copies the url and sends you back to Safari.

Upload to imgur from Quicksilver

I’ve become very fond of attaching animated GIF’s of new UI elements when I create pull requests at Firmafon. Recording a part of the screen is very easy using Quicksilver’s built-in screen recording and trimming features. Then when done, open the file in GIF Brewery and make it a gif. I usually lock the FPS to 15 and use the Simple Palette.

So far so good, we have a gif. Let’s put it somewhere we can reference. Imgur is great and keeps the images around for a long enough time for our colleagues to see it on Github. Luckily a command-line client for imgur already exists so grab imguru from Github and put it in ~/bin (or anywhere you’d like).

Quicksilver knows Applescript and supports custom actions in ~/Library/Application Support/Quicksilver/Actions, so open up AppleScript Editor.app and make a script with the following:

using terms from application "Quicksilver"
  on open theFile
    try
      set filePath to POSIX path of theFile
      set theCommand to "~/bin/imguru '" & filePath & "'"
      return do shell script theCommand
    on error e number n
      return e
    end try
  end open

  -- Tell Quicksilver we only work with files
  on get direct types
    return {"NSFilenamesPboardType"}
  end get direct types
end using terms from

Save it as Upload to imgur.scpt or something like it and you might have to restart Quicksilver and you’re there.

← PreviousPage 6 of 6

Pages

  • /uses — My current setup

COMPUTERS (Danish)RSS

Danish newsletter on life with computers

Past issues

PostsRSS

Musings on building software