Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A PowerShell ISE script to send selected text as a Github gist. This requires my New-GitHubGist function.
#requires -version 4.0
#dot source the script with the New-GitHubGist function
. C:\scripts\New-GitHubGist.ps1
Function SendTo-Gist {
[Parameter(Position = 0)]
[string[]]$Text = $psise.CurrentFile.Editor.SelectedText,
#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) {
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
You can’t perform that action at this time.