PowershellUtils
Run powershell commands from within Sublime Text.
Details
Installs
- Total 5K
- Win 4K
- Mac 370
- Linux 132
Dec 3 | Dec 2 | Dec 1 | Nov 30 | Nov 29 | Nov 28 | Nov 27 | Nov 26 | Nov 25 | Nov 24 | Nov 23 | Nov 22 | Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | Nov 10 | Nov 9 | Nov 8 | Nov 7 | Nov 6 | Nov 5 | Nov 4 | Nov 3 | Nov 2 | Nov 1 | Oct 31 | Oct 30 | Oct 29 | Oct 28 | Oct 27 | Oct 26 | Oct 25 | Oct 24 | Oct 23 | Oct 22 | Oct 21 | Oct 20 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
PowershellUtils package for Sublime Text
This plugin provides an interface to filter buffer text through a Windows Powershell pipeline and run and capture Powershell commands.
Requirements
Windows Powershell v2
Windows Powershell v2 is preinstalled in Windows 7 and later and it's available for previous versions of Windows too under the name Windows Management Framework.
Powershell is a powerful languange and needs to be used carefully to avoid undesired effects.
Getting Started
- Install PowershellUtils
- Install AAAPackageDev (dependency)
If you're running a full installation, simply double click on the .sublime-package files. If you're running a portable installation, perform an installation by hand.
Lastly, run run_powershell from the Python console or bind this command to a key combination:
# In Sublime's Python console. view.run_command("sublime_cmd")
Using The Windows Powershell Pipeline
- Execute run_powershell
- Type in your Windows Powershell command
- Press enter
All the currently selected regions in Sublime Text will be piped into your command sequencially. In turn, you can access each of this regions through the $_ automatic variable.
Roughly, this is what goes on behind the scenes:
reg1..regN | <your command> | out-string
You can ignore the piped content and treat your command as the start point of the pipeline.
The generated output will be inserted into each region in turn.
Using Intrinsic Commands
(Not all intrinsic commands work.)
The following commands have a special meaning for this plugin:
- !mkh
- Saves the session's history of commands to a file.
- !h
- Brings up the history of commands so you can choose one and run it again.
Examples
- $_.toupper()
- Turns each region's content to all caps.
- $_ -replace "\\","/"
- Replaces each region's content as indicated.
- "$(date)"
- Replaces each region's content with the current date.
- "$pwd"
- Replaces each region's content with the current working directory.
- [environment]::GetFolderPath([environment+specialfolder]::MyDocuments)
- Replaces each region's content with the path to the user's My Documents folder.
- 0..6|%{ "$($_+1) $([dayofweek]$_)" }
- Replaces each region's content with the enumerated week days.
Caveats
To start a Windows Powershell shell, do either Start-Process powershell or cmd /k start powershell, but don't call Windows Powershell directly because it will be launched in windowless mode and will block Sublime Text forever. Should this happen to you, you can execute the following command from an actual Windows Powershell prompt to terminate all Windows Powershell processes except for the current session:
Get-Process powershell | Where-Object { $_.Id -ne $PID } | Stop-Process
Alternatively, you can use a shorter version:
gps powershell|?{$_.id -ne $pid}|kill
Other Ways of Using PowershellUtils
PowershellUtils can be called with arguments so that the prompt is bypassed. This is interesting if you want to integrate powershell with a separate plugin.