Last active
May 13, 2016 18:41
-
-
Save gerane/9f133d183ab2b87733c2227c06597ac5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Import-Module -Name Emojis | |
function Invoke-EmojiSelection { | |
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 | |
function Invoke-EmojiList { | |
param([Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context) | |
$Names = (Get-Command -name Get-Emoji).Parameters['Name'].Attributes.ValidValues | |
$caption = "Please select an Emoji" | |
$message = " " | |
[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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment