Last active
November 13, 2020 18:06
-
-
Save jdhitsolutions/345a6b8e4c47440df5fb1dbcb987cb3e to your computer and use it in GitHub Desktop.
A PowerShell ISE script to send selected text as a Github gist. This requires my New-GitHubGist function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires -version 4.0 | |
#dot source the script with the New-GitHubGist function | |
. C:\scripts\New-GitHubGist.ps1 | |
Function SendTo-Gist { | |
[cmdletbinding()] | |
Param( | |
[Parameter(Position = 0)] | |
[ValidateNotNullorEmpty()] | |
[string[]]$Text = $psise.CurrentFile.Editor.SelectedText, | |
[switch]$Private | |
) | |
#hashtable of parameters to splat to New-GitHubGist | |
$param = @{ | |
name = (Read-Host "Enter a file name for your gist") | |
description = (Read-Host "Enter a description") | |
Content = $Text | |
} | |
if ($private) { | |
$param.Add("Private",$True) | |
} | |
New-GitHubGist @param | |
} | |
#add a menu shortcut | |
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.add("Send to Gist",{SendTo-Gist -text $psise.CurrentFile.Editor.SelectedText },$null) | out-null | |
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.add("Send to Private Gist",{SendTo-Gist -text $psise.CurrentFile.Editor.SelectedText -private},$null) | out-null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment