Skip to content

Get/Set-Clipboard command missing from PowerShell Core Edition on Mac #3618

Closed

Description

PowerShell Core Edition doesn't have a Set-Clipboard command. I've tried using pbcopy on Mac OS X, but it doesn't seem to work well with certain UTF-8 characters, like emojis. For example, using my Emojis PowerShell module, on the PowerShell Gallery, the pbcopy command pastes an emoji into my web browser as a question mark.

Having a high-quality Set-Clipboard command would be convenient from a first-class PowerShell perspective, and resolving bugs similar to those with pbcopy.

Cheers,
Trevor Sullivan

Activity

  1. pcgeek86 commented on Apr 21, 2017

    @pcgeek86
    Author

    Related ticket: #3177

  2. added
    Issue-Enhancement
    on Apr 23, 2017
  3. iSazonov commented on Apr 23, 2017

    @iSazonov
    Collaborator

    From Steve Lee (@SteveL-MSFT):

    At this time the Clipboard cmdlets are not compatible with PSCore6 as it depends on a System.Windows.Forms class which isn't part of corefx and would not be cross platform compatible.

    I do think the clipboard cmdlets are useful, but should be a separate module that is cross platform compatible which may require different code paths per OS.

  4. iSazonov commented on Apr 23, 2017

    @iSazonov
    Collaborator

    Trevor Sullivan (@pcgeek86) Could you make the Issue more common and change the title to "Get/Set-Clipboard commands missing from PowerShell Core"?

  5. changed the title [-]Set-Clipboard command missing from PowerShell Core Edition on Mac[/-] [+]Get/Set-Clipboard command missing from PowerShell Core Edition on Mac[/+] on Apr 23, 2017
  6. BrucePay commented on Apr 24, 2017

    @BrucePay
    Collaborator

    pbcopy/pbpaste should work. Trevor Sullivan (@pcgeek86) Have you investigated to see if this is an encoding problem? It would be nice if Out-Clipboard could just be an alias to pbcopy.

  7. mklement0 commented on Apr 25, 2017

    @mklement0
    Contributor

    It is indeed an encoding issue: because $OutputEncoding defaults to ASCII, any non-ASCII chars. are converted to literal ? chars:

     > 'ö' | pbcopy; pbpaste | od -tx1
     0000000    3f  0a                                                        
     0000002
    

    3f is literal ? (and 0a is \n).

    If you set $OutputEncoding to BOM-less UTF-8, it works:

     > & { $OutputEncoding = [System.Text.Utf8Encoding]::New(); 'ö' | pbcopy; pbpaste | od -tx1 }
     0000000    c3  b6  0a                                                    
     0000003
    

    c3 b6 is the UTF-8 encoding of ö, proving that the value was copied correctly.

  8. gradinkov commented on Mar 29, 2018

    @gradinkov

    Definitely a must have.

  9. SteveL-MSFT commented on May 22, 2018

    @SteveL-MSFT
    Member
  10. added
    Resolution-External
    on May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-EnhancementResolution-ExternalWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions