Writing PowerShell Code on OS X using Sublime

The majority of my PowerShell code is written in a Windows VM where all the typical native PowerShell tools are available. However, occasionally I may want to quickly view or make small changes to some code in OS X. It’s possible via the built-in TextEdit application, but that’s kind of the equivalent of using Notepad on Windows, i.e. a pretty basic experience.

I recently read this review of Text Editors on The Register and decided to check out Sublime after discovering PowerShell could be added as an additional language to support syntax highlighting.

First of all download and install Sublime (available for OS X, Windows and Linux). To add PowerShell syntax highlighting:

  1. Download the zip file from https://github.com/SublimeText/PowerShell

  2. Unzip and move the contents to Users\Username\Library\Application Support\Sublime Text 2\Packages

Note: I couldn’t track this down at first, the instructions stated to copy to the Packages folder, but not exactly where that would be. Fortunately, there is a menu item which will take you straight there:

  1. Restart Sublime and now PowerShell v2 will be listed as an available syntax

Now you can work with PowerShell (and other) code in a nice interface