r/PowerShell • • Mar 15 '16

¯\_(ツ)_/¯

function Get-AsciiShrug {
    $OutputEncoding = [System.Text.Encoding]::unicode
    write-output "¯_($(0x30C4|%{[char]$_}))_/¯" | clip
}
144 Upvotes

48 comments sorted by

View all comments

27

u/sup3rmark Mar 15 '16

I got sick of googling "ascii shrug" and copy/pasting from there all the time so i just put this function into my powershell profile.

2

u/derekhans Mar 15 '16

It'd be fun to flesh out more of this function. Is there an easy way to interpret the ascii code for these?

3

u/gangstanthony Mar 15 '16 edited Mar 15 '16

if you find the one you want (I'm using this site)

https://www.wikiwand.com/en/List_of_emoticons

you can copy/paste it into the ISE and do this to see the numbers:

[int[]][char[]]'ಠ_ಠ' -join ', '

gives

3232, 95, 3232

so we can do this

-join[char[]](3232,95,3232)

*note: OP is using hex, but it would work just as well with the decimal number

[char]12484

another example

[int[]][char[]]'(╯°□°)╯︵ ┻━┻' -join ', '

gives

40, 9583, 176, 9633, 176, 65289, 9583, 65077, 32, 9531, 9473, 9531

then we can mix and match

-join[char[]](40, 9583, 3232, 9633, 3232, 65289, 9583, 65077, 32, 9531, 9473, 9531)

*improved thanks to /u/da_chicken

13

u/spoonstar Mar 15 '16

I may or may not have used this to do this:

  function Get-Ascii {
    [cmdletbinding()]

    param (
        [switch]$Shrug,
        [switch]$Disapproval,
        [switch]$TableFlip,
        [switch]$TableBack,
        [switch]$TableFlip2,
        [switch]$TableBack2,
        [switch]$TableFlip3,
        [switch]$Denko,
        [switch]$BlowKiss,
        [switch]$Lenny,
        [switch]$Angry,
        [switch]$DontKnow
     )
     $OutputEncoding = [System.Text.Encoding]::unicode

     Switch ($PSBoundParameters.GetEnumerator().
      Where({$_.Value -eq $true}).Key)
     {
       # 'NAME' { [char[]]@() -join '' | clip }
       'Shrug' { [char[]]@(175,92,95,40,12484,41,95,47,175) -join '' | clip}
       'Disapproval' { [char[]]@(3232,95,3232) -join '' | clip }
       'TableFlip' { [char[]]@(40,9583,176,9633,176,65289,9583,65077,32,9531,9473,9531,41) -join '' | clip }
       'TableBack' { [char[]]@(9516,9472,9472,9516,32,175,92,95,40,12484,41) -join '' | clip }
       'TableFlip2' { [char[]]@(9531,9473,9531,32,65077,12541,40,96,1044,180,41,65417,65077,32,9531,9473,9531) -join '' | clip }
       'TableBack2' { [char[]]@(9516,9472,9516,12494,40,32,186,32,95,32,186,12494,41) -join '' | clip }
       'TableFlip3' { [char[]]@(40,12494,3232,30410,3232,41,12494,24417,9531,9473,9531) -join '' | clip }
       'Denko' { [char[]]@(40,180,65381,969,65381,96,41) -join '' | clip }
       'BlowKiss' { [char[]]@(40,42,94,51,94,41,47,126,9734) -join '' | clip}
       'Lenny' { [char[]]@(40,32,865,176,32,860,662,32,865,176,41) -join '' | clip }
       'Angry' { [char[]]@(40,65283,65439,1044,65439,41) -join '' | clip }
       'DontKnow' { [char[]]@(9488,40,39,65374,39,65307,41,9484) -join '' | clip }
     }
  }

10

u/codekaizen Mar 15 '16

Nice, though I'd prefer this encoding of the parameters:

[ValidateSet(
    'Shrug',
    'Disapproval',
    'TableFlip',
    'TableBack',
    'TableFlip2',
    'TableBack2',
    'TableFlip3',
    'Denko',
    'BlowKiss',
    'Lenny',
    'Angry',
    'DontKnow')]
[string]$Name

Then I can lazily cycle through them.

3

u/spoonstar Mar 15 '16

It does the same thing, I just have to prepend a hyphen beforehand. ValidateSet does make it quicker for me to add new ones though, so thanks for reminding me about it!

10

u/MattHodge Mar 16 '16

I have created a new version with all your ideas: https://github.com/MattHodge/MattHodgePowerShell/blob/master/Fun/Get-Ascii.ps1

  • Uses Validate Parameters

  • Outputs to console as well as clipboard

  • Doesn't copy the newline to the clipboard

2

u/gbrayut Mar 16 '16

Nice work!

2

u/mcwidget Mar 16 '16

This is great. I may have stolen it.

1

u/spoonstar Mar 16 '16

No newline! Great!