Unless you’ve been living under a rock, you’ve probably heard about Sublime Text 2. This app is a cross-platform (*nix, OSX and Windows) text editor, and is a successor to the Windows-only Sublime Text. Despite it currently being in beta, Sublime has tons of features that make it a powerful text editor.

One of the cool features in Sublime is the build function (TextMate has this as well). You can write a ruby script and then run it within the text editor. The result will print out in Sublime’s console. This can be handy for testing a script, or just fun to play with. You can also require files and run an entire application with it.

Another cool app for all of the rubyists out there is rvm. It’s a ruby version manager, giving you the ability to “hot swap” between different ruby installs. So if you have an app that requires 1.8, but you have 1.9.2, you can just type in rvm use 1.8 and your terminal session will switch to using 1.8. You can also manage multiple gemsets, helping keep things in order and nice and separate.

When I work with rvm, I like to set my default ruby to a version that I use all the time. In this case it’s 1.9.2. I only need to swap generally in special cases. The --default is great, but the problem with RVM is that it is loaded into your console via your profile. When Sublime runs it’s build script, it doesn’t look for your ~/.bash_profile, instead it loads your PATH’s ruby instead (in this case, /usr/bin/ruby).

The Problem

I want to get Sublime to load RVM before it runs ruby.

The Solution

Thanks to Robert, this post has been updated with a simpler solution. This should be compatible with Linux users.

Edit your build function

Navigate to your Sublime Packages folder, go to the Ruby folder and find the Ruby.sublime-build file. Edit it so that it is like this:

Ruby.sublime-build
1
2
3
4
5
{
    "cmd": ["HOME_DIRECTORY/.rvm/bin/rvm-auto-ruby", "$file"],
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "selector": "source.ruby"
}

Note: you must specify the absolute path to your home folder. ~ does not work in this case.

If you’ve done everything right, you should be able to build your Ruby files now in your rvm’s default ruby.

BONUS: Use .rvmrc

When you run rvm-auto-ruby instead of ruby, rvm will use your –default ruby/gemset combo. It will also check for any .rvmrc files and use the ruby/gem combo specified in that file. If you require using a separate ruby/gemset combo from your default (e.g. jruby) you can add this to your projects’ root folder. The rvm official site provides excellent documentation on this feature and how to use it.

{ 7 comments }

Since the beginning of time, developers always had the issue of migrating their workflow from work to home. Having a laptop has relieved this issue, but for many of us who use multiple computers, it remains a minor discrepancy in the steaming pile of problems. Working from home isn’t a burden we’d ever want to take, but our environment was always decentralized amongst different locations. One computer has one setup, the other has another. It was never perfect, but fortunately solutions lay on the horizon.

There has been much effort put towards decentralizing our workflow, making one place the exact same instance as the next. Google’s ChromeOS is a perfect, if simple, example a centralized computing experience. You log off one computer, and log on another and your “session” is intact. This is because your session is stored within the cloud. It requires an active internet connection to use this feature, but for a majority of the situations that you use a cloud-based operating system for, it works.

Google’s ChromeOS is an operating system based on Google’s Chrome browser, and it fits nicely with Google’s ideology: to keep your information in one place. Google Chrome itself, has a smaller, much more adaptive instance of this idea and it’s embedded into Google’s Sync feature inside Google Chrome.

Google Chrome’s Sign In feature allows you to log in with your Google Account and sync your preferences, bookmarks, extensions, and even history within your browser amongst other computers that have signed in to your Google Account. This data is encrypted, and can be salted with your own unique password (it’s optional, but highly recommended if you’re scared of data thieves). This is a nice feature, but nothing new to the table with Firefox’s Sync and Opera’s Link features. Still, it’s a useful feature and is one of the first things I do when I set up my computer.

Switching between profiles is a two-click process.

What is new and exciting to Google Chrome is the Profiles feature. This feature allows you to quickly switch between one “browser profile” to the next, and in a nutshell it builds on top of the Google Chrome Sign In feature. A profile (can be) a Google Account that has been signed into your computer. Each profile is, essentially, it’s own instance of Google Chrome. Everything is separate between each profile: bookmarks, themes, extensions, preferences, history, passwords, and so on. You can also sign in to a different Google Account on each profile, so if you have Gmail and your work has Google Apps, you’re just a two-step process away from separating work with play.

Cool, but how does this improve my workflow? I need an example.

Before this update, I was forced into a merged home/work browser-hell involving Facebook and Reddit bookmarks next to Harvest and Basecamp. While it’s cool to have all of your links up there and ready to go, for people like me, this is a gigantic distraction. Typically, while at work, I tend to open Reddit while a page refresh takes forever. It’s up to you to judge, but in my opinion, it breaks my train of thought.

Basically, it can keep you from working when you don’t need to. Keep your NFL and Facebook extensions on the play-side, and keep your Web Developer and Firebug extensions on the work-side.

Just a tip, thought I’d share. I find it to be an incredibly useful feature for keeping myself focused as the Internet can get extremely distracting.

* * *

TL;DR: Google Chrome’s Sign In feature provides a simple and reliable way to keep your data in one spot amongst multiple computers by using your Google Account. Google Chrome’s multi-user Profiles feature allows you to keep multiple Google Accounts synced and provides a quick and simple way to switch between them, thus alleviating workflow constraints caused by only having one single account for multiple workflows.

More info about Google’s Sign In feature here.

More info about Google’s Profile feature here.

{ 0 comments }