PowerShell Studio with GIT, Subversion and Mercurial Oh, my!
- Written by David Corrales
- Last Updated: 22 April 2016
- Created: 08 January 2013
- Hits: 3917
Similar to PrimalScript, we received requests to add support for GIT, Mercurial, and Subversion in PowerShell Studio. The difficulty of supporting all these various source control solutions is that they all have different APIs and change over time. The varying nature of these tools could potentially make the integration outdated fairly quickly. One thing in common all the source controls solutions previously mentioned have is command line tools. We’ve used this common factor to resolve the problem.
Our solution to the problem is the custom tool menu:
The custom tool menu allows you to customize and execute command lines tools at the click of a button. The new feature enables you to integrate virtually any solution that provides a command line tool.
You can add a global set of commands to the custom tool menu by creating an INF file in PowerShell Studio’s application data folder:
Folder Location (Windows 7 ):
C:\ProgramData\SAPIEN\PowerShell Studio [YEAR]\CustomMenu.inf
1=Command Name 1;command line 1
2=Command Name 2;command line 2
In this example GIT is used, but any command line tool will work including the command line tools you create with PowerShell Studio’s script to exe packager.
After creating or altering the CustomMenu.inf, you will need to restart PowerShell Studio in order to see the new commands:
Another useful feature of the custom menu is the ability to create localized commands for specific folders. For example, you may use a particular source control solution for Folder A and another for Folder B. In addition, you could use the localized commands to replicate a source control solution’s repository to a remote location.
For example, the following CustomMenu.inf is added to the target folder “My Documents\SAPIEN\Scripts”:
When you open a file that is contained in the folder, the custom tools menu will display the localized folder commands as well as the global commands.
The custom commands allow you to react to files or folders. This way you can push files to an ftp site or simply make a backup copy to a remote location. Output from the command line tools will be displayed in PowerShell Studio’s Output panel.
The following is a list of macro variables that can be used in custom menu command lines:
$ProjectFolder$ The folder the currently open project resides in, if any project is open. $PowerShell$ The PowerShell version number currently selected in the ribbon (2 or 3). $Platform$ The current platform selected in platform selector (32 or 64) $WinDir$ The location of the Windows directory for PowerShell Studio’s process. $WinSystem$ The location of the Windows System folder for PowerShell Studio’s process. $Selection$ The content of the current selection in the active file, if any. (Warning: may contain carriage return/ linefeed) $File$ The full path of the currently active file, if any. $FileName$ The file name of the active document without path information. $FileDir$ The folder location of the currently active document. $Dir$ The current directory of PowerShell Studio’s process. $Line$ The current line number in the active file. $Col$ The current column in the active file.
The custom menu feature should make PowerShell Studio integration with external tools easier and customizable.
This article applies to PowerShell Studio v3.1.14 or later.