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.
First of all download and install Sublime (available for OS X, Windows and Linux). To add PowerShell syntax highlighting:
Download the zip file from https://github.com/SublimeText/PowerShell
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:
- 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