{"id":18980875,"url":"https://github.com/sublimetext/powershellutils","last_synced_at":"2025-09-09T14:11:39.436Z","repository":{"id":66974255,"uuid":"1657969","full_name":"SublimeText/PowershellUtils","owner":"SublimeText","description":"Run powershell commands from within Sublime Text.","archived":false,"fork":false,"pushed_at":"2011-04-25T10:31:34.000Z","size":227,"stargazers_count":16,"open_issues_count":3,"forks_count":2,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-29T12:11:11.445Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SublimeText.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-04-24T22:37:42.000Z","updated_at":"2024-06-09T19:17:11.000Z","dependencies_parsed_at":"2023-02-20T15:35:18.376Z","dependency_job_id":null,"html_url":"https://github.com/SublimeText/PowershellUtils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SublimeText%2FPowershellUtils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SublimeText%2FPowershellUtils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SublimeText%2FPowershellUtils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SublimeText%2FPowershellUtils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SublimeText","download_url":"https://codeload.github.com/SublimeText/PowershellUtils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249239351,"owners_count":21235852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T16:08:05.709Z","updated_at":"2025-04-16T12:31:14.657Z","avatar_url":"https://github.com/SublimeText.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"========================================\r\nPowershellUtils package for Sublime Text\r\n========================================\r\n\r\nThis plugin provides an interface to filter buffer text through a Windows\r\nPowershell pipeline and run and capture Powershell commands.\r\n\r\nRequirements\r\n============\r\n\r\n**Windows Powershell v2**\r\n\r\nWindows Powershell v2 is preinstalled in Windows 7 and later and it's available\r\nfor previous versions of Windows too under the name `Windows Management Framework`.\r\n\r\nPowershell is a powerful languange and needs to be used carefully to avoid\r\nundesired effects.\r\n\r\nGetting Started\r\n===============\r\n\r\n* Install `PowershellUtils`_\r\n* Install `AAAPackageDev`_ (dependency)\r\n\r\n.. _PowershellUtils: https://bitbucket.org/guillermooo/powershellutils/downloads/PowershellUtils.sublime-package\r\n.. _AAAPackageDev: https://bitbucket.org/guillermooo/aaapackagedev/downloads/AAAPackageDev.sublime-package\r\n\r\nIf you're running a full installation, simply double click on the ``.sublime-package`` files.\r\nIf you're running a portable installation, perform an `installation by hand`_.\r\n\r\n.. _installation by hand: http://sublimetext.info/docs/extensibility/packages.html#installation-of-packages-with-sublime-package-archives\r\n\r\nLastly, run ``run_powershell`` from the Python console or bind this command to\r\na key combination::\r\n\r\n   # In Sublime's Python console.\r\n   view.run_command(\"sublime_cmd\")\r\n\r\n\r\nUsing The Windows Powershell Pipeline\r\n=====================================\r\n\r\n1. Execute ``run_powershell``\r\n2. Type in your Windows Powershell command\r\n3. Press ``enter``\r\n\r\nAll the currently selected regions in Sublime Text will be piped into your\r\ncommand sequencially. In turn, you can access each of this regions through the\r\n``$_`` automatic variable.\r\n\r\nRoughly, this is what goes on behind the scenes::\r\n\r\n    reg1..regN | \u003cyour command\u003e | out-string\r\n\r\nYou can ignore the piped content and treat your command as the start point of\r\nthe pipeline.\r\n\r\nThe generated output will be inserted into each region in turn.\r\n\r\nUsing Intrinsic Commands\r\n------------------------\r\n\r\n(Not all intrinsic commands work.)\r\n\r\nThe following commands have a special meaning for this plugin:\r\n\r\n    ``!mkh``\r\n        Saves the session's history of commands to a file.\r\n    ``!h``\r\n        Brings up the history of commands so you can choose one and run it again.\r\n\r\nExamples\r\n--------\r\n\r\n``$_.toupper()``\r\n    Turns each region's content to all caps.\r\n``$_ -replace \"\\\\\",\"/\"``\r\n    Replaces each region's content as indicated.\r\n``\"$(date)\"``\r\n    Replaces each region's content with the current date.\r\n``\"$pwd\"``\r\n    Replaces each region's content with the current working directory.\r\n``[environment]::GetFolderPath([environment+specialfolder]::MyDocuments)``\r\n    Replaces each region's content with the path to the user's ``My Documents`` folder.\r\n``0..6|%{ \"$($_+1) $([dayofweek]$_)\" }``\r\n    Replaces each region's content with the enumerated week days.\r\n\r\nCaveats\r\n-------\r\n\r\nTo start a Windows Powershell shell, do either ``Start-Process powershell`` or\r\n``cmd /k start powershell``, but don't call Windows Powershell directly because\r\nit will be launched in windowless mode and will block Sublime Text forever.\r\nShould this happen to you, you can execute the following command from an actual\r\nWindows Powershell prompt to terminate all Windows Powershell processes except\r\nfor the current session::\r\n\r\n    Get-Process powershell | Where-Object { $_.Id -ne $PID } | Stop-Process\r\n\r\nAlternatively, you can use a shorter version::\r\n\r\n    gps powershell|?{$_.id -ne $pid}|kill\r\n\r\n\r\nOther Ways of Using PowershellUtils\r\n===================================\r\n\r\nPowershellUtils can be called with arguments so that the *prompt* is bypassed.\r\nThis is interesting if you want to integrate powershell with a separate plugin.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsublimetext%2Fpowershellutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsublimetext%2Fpowershellutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsublimetext%2Fpowershellutils/lists"}