Kaleidoscope 5 introduces a groundbreaking feature that allows users to effortlessly open the changeset for any Git commit. This feature comes in two distinct forms tailored to accommodate all macOS applications: one leveraging a system service and the other integrated with Kaleidoscope Prism. Both options can be further optimized by adding a keyboard shortcut for swift execution.
To kick things off, here’s a brief video showcasing both implementations in action.
“We got both kinds, we got country and western”1
In the early times of OS X, we had two kinds of apps: Carbon apps that were mostly brought over from classic Mac OS. They didn’t integrate with some of the more advanced parts of the operating system. Then there were the modern Cocoa apps, which automatically benefitted from modern technologies like services. The term modern is a bit of a stretch here, as services date back to Cocoa in early NeXTSTEP.
It’s 20+ years later, and we once again have two sorts of apps: native apps, written using technologies like Cocoa or SwiftUI, even called legacy apps by some, and web-based apps using some runtime like Electron, by some considered modern and hip, bloated by others. Those apps often barely recognize the underlying operating system and usually can’t benefit from inventions made on macOS. Those “modern” apps mostly don’t support services, so part 2 of this article will offer a solution for those. And to be fair, sometimes it may just be preferable to use that method.
The system service
For those of you asking: we’re talking about a macOS Service. Here’s the one sentence summary from the macOS User Guide:
Services let you use features of other apps for the task you’re doing without having to open those apps.
Services typically manifest themselves in two places:
- The Services submenu of application menu of the app. For example, in Notes open the main menu Notes, then look for an entry Services.
- A Services submenu in the contextual menu, if applicable. Again, in Notes, select some text in a note, then bring up the contextual menu. You should see an entry Services at the bottom.
What’s nice about services in addition to them being omnipresent is that they don’t occupy your clipboard. No need to copy any text before using a service on it, selecting text is sufficient.
In Kaleidoscope 5, there’s a new service with the long-winded but self-explanatory name Open Changeset in Kaleidoscope.
By now, usage is obvious:
- Find a (short) hash display in any app
- Select that text
- Bring up the contextual menu (or head to the app menu)
- Select Services > Open Changeset in Kaleidoscope
- The changeset opens, there’s no additional step
If you can’t see Open Changeset in Kaleidoscope, open System Settings > Keyboard > Keyboard Shortcuts > Services > Text and ensure that it is enabled there. This is also the place to set up a keyboard shortcut for the service.
Kaleidoscope Prism
As noted above, certain apps don’t support services. Popular examples are the free GitHub Desktop git client, the GitKraken git client, and Slack, all Electron-based web apps.
For those, we are going to use Kaleidoscope Prism from the menu bar to achieve almost the same. If you aren’t familiar with Kaleidoscope Prism and how to ensure it’s running when you need it, consult our dedicated blog post.
First, you need to find a way to copy the commit identifier (hash, SHA, …) to the clipboard. That may vary between apps. Here are the 3 examples mentioned above:
GitHub Desktop
In GitHub Desktop, find the small copy button in the header of a commit. As an alternative, bring up the contextual menu of a history entry and select Copy SHA.
GitKraken
In GitKraken, ensure the Commit Details Panel is shown. Click the short commit hash next to the word commit. As an alternative, in the commits list, bring up the contextual menu of an entry and select Copy commit sha.
Slack
In Slack, bring up the contextual menu anywhere you see a short commit hash. From the menu, select Copy this code.
The process:
- Find a way to copy the commit identifier to the clipboard
- Head to the Kaleidoscope Prism menu
- Select Send Clipboard to New Changeset
- Once again, no additional step, the changeset opens.
How does Kaleidoscope know about my commit?
Git identifies every commit in a repository using a 40 character hexadecimal hash that’s pretty unique. Git officially calls this object name, but it’s commonly called commit identifier, commit hash, or SHA-1, because this hexadecimal code is calculated using the SHA-1 hashing function. Given those 40 characters, git can locate that commit in a repository.
Most of the time, it’s good enough to use the first 8 of those 40 characters. Many apps only show this so-called short hash. Kaleidoscope shows the 8 character short hash by default, but hovering over any of those displays will reveal the full 40 characters.
As a second ingredient, Kaleidoscope needs to know the repository for a particular commit. As you probably guessed, Kaleidoscope tries all the repositories you have added to the Recent Repositories list, either by comparing files in a repository or by explicitly adding it. In other words, Kaleidoscope does not automatically scan your hard drive, you need to let Kaleidoscope know that it should recognize a repository. Otherwise, opening a changeset won’t work.