r/PowerShell • • Mar 15 '16

¯\_(ツ)_/¯

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

48 comments sorted by

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.

5

u/ihaxr Mar 15 '16

... and into mine it goes.

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.

→ More replies (5)

2

u/da_chicken Mar 15 '16

No need for the loop:

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

[char[]]@(3232,95,3232) -join ''
→ More replies (1)

1

u/runninginthedark Mar 18 '16

Yup, here you go.

function Show-AsciiFace{
    param(
        $Name = "Shrug"
    )
    
    $OutputEncoding = [System.Text.Encoding]::unicode
    
    switch ($Name){
        {$_ -like "Shrug*"}{return $([char[]](0xAF,0x5C,0x5F,0x28,0x30C4,0x29,0x5F,0x2F,0xAF)) -join ""}
        {$_ -like "Flip*"}{return $([char[]](0x28,0x256F,0xB0,0x25A1,0xB0,0xFF09,0x256F,0xFE35,0x253B,0x2501,0x2501,0x253B)) -join ""}
        {$_ -like "DoubleFlip*"}{return $([char[]](0x253B,0x2501,0x2501,0x253B,0xFE35,0x20,0x5C,0x28,0xB0,0x25A1,0xB0,0x29,0x2F,0x20,0xFE35,0x20,0x253B,0x2501,0x2501,0x253B)) -join ""}
        {$_ -like "Fix*"}{return $([char[]](0x252C,0x2500,0x2500,0x252C,0x20,0xFF89,0x28,0xB0,0x2014,0xB0,0xFF89,0x29)) -join ""}
        {$_ -like "Sunglasses*"}{return $([char[]](0x28,0x20,0x2022,0x5F,0x2022,0x29,0x20,0x28,0x20,0x2022,0x5F,0x2022,0x29,0x3E,0x2310,0x25A0,0x2D,0x25A0,0x20,0x28,0x2310,0x25A0,0x5F,0x25A0,0x29)) -join ""}
        {$_ -like "Disapprove*"}{return $([char[]](0xCA0,0x5F,0xCA0)) -join ""}
        {$_ -like "Angry*"}{return $([char[]](0x28,0x22DF,0xFE4F,0x22DE,0x29)) -join ""}
        {$_ -like "You*"}{return $([char[]](0x261E,0x28,0xFF9F,0x2200,0xFF9F,0x29,0x261E)) -join ""}
        {$_ -like "Gimmie*"}{return $([char[]](0xF3C,0x20,0x3064,0x20,0x25D5,0x5F,0x25D5,0x20,0xF3D,0x3064)) -join ""}
        {$_ -like "Yay*"}{return $([char[]](0x5C,0x28,0x2C6,0x2DA,0x2C6,0x29,0x2F)) -join ""}
        {$_ -like "ManTears*"}{return $([char[]](0xCA5,0x5F,0xCA5)) -join ""}
        {$_ -like "KeepAnEyeOut*"}{return $([char[]](0x28,0xCA0,0x5F,0x78,0x29,0x20,0xF3C,0x2609)) -join ""}
        {$_ -like "Fight*"}{return $([char[]](0x28,0xE07,0x2022,0x5F,0x2022,0x29,0xE07)) -join ""}
        default{
            write-Host "I don't recognize $Name"
            return $([char[]](0xAF,0x5C,0x5F,0x28,0x30C4,0x29,0x5F,0x2F,0xAF)) -join ""
        }
    }
}

function Get-AsciiFromString{
    param(
        $InputString
    )
    
    return "0x$(($([int[]][char[]]("$InputString")) | % {"{0:X0}" -f $_}) -join ",0x")"
}

0

u/[deleted] Mar 15 '16

[deleted]

2

u/[deleted] Mar 16 '16

The hero we need. This site will be getting a lot of hits from me.

→ More replies (3)

3

u/tehjimmeh Mar 16 '16 edited Mar 16 '16

If you save the file as UTF8 (default ISE encoding, AFAIK), you can just do:

function Get-AsciiShrug {
    $OutputEncoding = [Text.Encoding]::utf8
    "¯_(ツ)_/¯" | clip
}

In ConEmu with the UTF8 codepage (chcp 65001) and Consolas font, the face displays. Not in the command prompt though (weird, seems like it should work there too).

Also, it's amusing how "ASCII" has gained a colloquial meaning of "non-standard characters". This example is very much not ASCII :)

1

u/sup3rmark Mar 16 '16

Haha I was wondering how long it would take for someone to comment on "ASCII." You're right.

2

u/StratoLion Mar 15 '16

I can't get this to work. How should I use it from Powershell ISE?

2

u/sup3rmark Mar 15 '16

i just added it to my powershell profile. do you have one of those set up? or some other module that you manually import all the time?

2

u/StratoLion Mar 15 '16

No I don't have a profile. I'm extremely noob on this.

5

u/gangstanthony Mar 15 '16

clip automatically puts it into the clipboard. you will see no output on the powershell console when this is run. just run the function then do ctrl+v to see the clipboard contents.

2

u/StratoLion Mar 15 '16

OMFG THIS IS AMAZING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2

u/GoGoGadgetWhiskey Mar 16 '16

I learned the pipe-to-clip trick watching those MS powershell video tutorials. It works in the regular command prompt as well! :)

I do this a lot:

C:\> systeminfo |clip
C:\> notepad 

and... paste

→ More replies (2)

1

u/freddyquell Mar 15 '16

Not sure what 'clip' does but removing that makes it work for me in the ISE.

2

u/sup3rmark Mar 15 '16

removing clip kind of renders this even more useless than it already is, though.

that said... ¯_(ツ)_/¯

3

u/da_chicken Mar 15 '16
PS C:\> where.exe clip
C:\Windows\System32\clip.exe
PS C:\> clip /?

CLIP

Description:
    Redirects output of command line tools to the Windows clipboard.
    This text output can then be pasted into other programs.

Parameter List:
    /?                  Displays this help message.

Examples:
    DIR | CLIP          Places a copy of the current directory
                        listing into the Windows clipboard.

    CLIP < README.TXT   Places a copy of the text from readme.txt
                        on to the Windows clipboard.

1

u/StratoLion Mar 15 '16

Yup! worked like a charm. Thanks.

0

u/[deleted] Mar 15 '16

[deleted]

2

u/omrsafetyo Mar 15 '16
Write-Host "Loading..."
Write-Host "Loading..."
Write-Host "Loading..."
Get-Shruggie
→ More replies (1)

2

u/OpiumPhrogg Mar 15 '16

For any of you android users, the app "Look of Disapproval" has a TON of ascii guys shrugging, flipping tables, etc..

https://play.google.com/store/apps/details?id=com.slaughter.look.of.disapproval&hl=en

1

u/sup3rmark Mar 15 '16

1

u/Whitestrake Mar 16 '16

This is amazing. I can swap between it and the Google keyboard with the little globe button. Perfect.

¯_(ツ)_/¯

18

u/Swarfega Mar 15 '16

Over engineered solution to a null issue, this is awesome!

5

u/Brekkjern Mar 15 '16

You should expand this to include the table flip and other emoji since you seem to be into over engineering things :P

5

u/boli99 Mar 16 '16

It's not ASCII - It's UNICODE.

ASCII stops at 255

4

u/freddyquell Mar 15 '16

set-alias gs Get-AsciiShrug

4

u/pohatu Mar 15 '16

Damn I miss powershell. I wonder how far along the osx compatible one is. Maybe I should help out with that project. Powershell is the best thing about Windows.

3

u/mister_wizard Mar 15 '16

Oh great, something else to add to my profile that i dont actually need! (Thanks, seriously this is pretty funny)

2

u/aaroniusnsuch Mar 15 '16

try

[string](0..8|%{[char][int]("001750009200095000401248400041000950004700175".Substring(($_*5),5))})-replace " "

2

u/halr9000 Mar 16 '16

OP is doing the Lord's work

2

u/Darkm27 Mar 16 '16

You gotta make it scale-able man

function Get-AsciiEmoji{
	[CmdletBinding()]
	param (
	[ValidateSet("Shrug","TableFlip")]
	[parameter(Mandatory = $false)]
	[string]$WhichOne
	)
	Process{
		$OutputEncoding = [System.Text.Encoding]::unicode

		[string]$Output
		switch($WhichOne){
			"TableFlip" { $Output = "(╯°□°)╯︵ ┻━┻" }
			"Shrug" { $Output = "¯_($(0x30C4|%{[char]$_}))_/¯" }
	   }

	   write-output $Output
	}
}

1

u/evetsleep Mar 15 '16

Looks at calendar...nope not Friday yet. This post is a few days early!

0

u/[deleted] Mar 16 '16

[deleted]

2

u/sup3rmark Mar 16 '16

Set-Clipboard

requires Windows Management Framework 5.0