Skip to content

Instantly share code, notes, and snippets.

@gerane
Created May 22, 2016 16:26
Show Gist options
  • Select an option

  • Save gerane/c87a640337a9739da746a18e1b62682f to your computer and use it in GitHub Desktop.

Select an option

Save gerane/c87a640337a9739da746a18e1b62682f to your computer and use it in GitHub Desktop.
Import-Module Emojis
function Invoke-EmojiSelection
{
[Cmdletbinding()]
param
(
[Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context
)
$EmojiText = $context.CurrentFile.GetText($context.SelectedRange)
$Emoji = Get-Emoji -Name $EmojiText
if ($Emoji)
{
$context.CurrentFile.InsertText($Emoji, $context.SelectedRange)
}
}
Register-EditorCommand `
-Name "Emojis.Invoke-EmojiSelection" `
-DisplayName "Replace selected text with emoji" `
-Function Invoke-EmojiSelection `
-SuppressOutput
function Invoke-EmojiList
{
[Cmdletbinding()]
param
(
[Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context
)
$Names = (Get-Command -name Get-Emoji).Parameters['Name'].Attributes.ValidValues
$caption = "Please select an Emoji"
$message = "Inserts Emoji at Cursor Position"
[int]$defaultChoice = 0
$Choices = [System.Management.Automation.Host.ChoiceDescription[]] @($Names)
$Name = $host.ui.PromptForChoice($caption,$message, $choices,$defaultChoice)
$Emoji = Get-Emoji -name $Names[$Name]
$context.CurrentFile.InsertText($Emoji, $context.CursorPosition)
}
Register-EditorCommand `
-Name "Emojis.EmojiFromList" `
-DisplayName "Inserts an Emoji from List" `
-Function Invoke-EmojiList `
-SuppressOutput
function Invoke-PlasterTemplate
{
[CmdletBinding()]
param
(
[Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context,
[Parameter(Mandatory=$true)]
[string]$Name = (Read-Host 'Please type Toolkit Name')
)
Process
{
$TemplatePath = "C:\Test\Templates\ModuleTemplate.zip"
$Destination = "C:\Test\$Name"
Invoke-Plaster -TemplatePath $TemplatePath -DestinationPath $Destination -ModuleName $Name
}
}
Register-EditorCommand `
-Name "Plaster.PlasterTemplate" `
-DisplayName "Start Plaster Template" `
-Function Invoke-PlasterTemplate `
-SuppressOutput
@zautke
Copy link

zautke commented Apr 13, 2020

Awesome, thanks for having this out there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment