{"id":14980386,"url":"https://github.com/mklement0/clipboardtext","last_synced_at":"2025-10-16T19:35:06.338Z","repository":{"id":86884749,"uuid":"133831414","full_name":"mklement0/ClipboardText","owner":"mklement0","description":"Universal clipboard text support for PowerShell, notably also in PowerShell Core (cross-platform) and Windows PowerShell v2-v4","archived":false,"fork":false,"pushed_at":"2020-08-15T12:47:04.000Z","size":95,"stargazers_count":43,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-01T20:11:25.273Z","etag":null,"topics":["cli","clipboard","powershell","powershell-core","powershell-module","unix","windows","windows-powershell"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mklement0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-17T15:14:52.000Z","updated_at":"2024-12-18T13:54:26.000Z","dependencies_parsed_at":"2023-03-27T15:09:19.288Z","dependency_job_id":null,"html_url":"https://github.com/mklement0/ClipboardText","commit_stats":{"total_commits":57,"total_committers":1,"mean_commits":57.0,"dds":0.0,"last_synced_commit":"f4a7926c0692309f716703e428128013466ac2bf"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mklement0%2FClipboardText","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mklement0%2FClipboardText/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mklement0%2FClipboardText/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mklement0%2FClipboardText/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mklement0","download_url":"https://codeload.github.com/mklement0/ClipboardText/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238743866,"owners_count":19523191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","clipboard","powershell","powershell-core","powershell-module","unix","windows","windows-powershell"],"created_at":"2024-09-24T14:01:41.594Z","updated_at":"2025-10-16T19:35:06.240Z","avatar_url":"https://github.com/mklement0.png","language":"PowerShell","readme":"[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/ClipboardText.svg)](https://powershellgallery.com/packages/ClipboardText) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mklement0/ClipboardText/blob/master/LICENSE.md)\n\n# Clipboard text support for PowerShell Core (cross-platform) and Windows PowerShell v2-v4\n\n`ClipboardText` is a **cross-edition, cross-platform PowerShell module** that provides support\nfor **copying text to and retrieving text from the system clipboard**, via the `Set-ClipboardText` and `Get-ClipboardText` cmdlets.\n\nIt is useful in the following **scenarios**:\n\n* **Use with PowerShell _Core_ on (hopefully) all supported platforms.**\n\n  * As of v6.1, PowerShell Core doesn't ship with clipboard cmdlets.\n  * This module fills this gap, albeit only with respect to _text_.  \n  * The implementation relies on external utilities (command-line programs) on all supported platforms:\n    * Windows: `clip.exe` (built in)\n    * macOS: `pbcopy` and `pbpaste` (built in)\n    * Linux: [`xclip`](https://github.com/astrand/xclip) (_requires installation_ via the system's package manager; e.g. `sudo apt-get install xclip`; available on X11-based [freedesktop.org](https://www.freedesktop.org/wiki/)-compliant desktops, such as on Ubuntu)\n\n* **Use with _older versions_ of _Windows PowerShell_.**\n\n  * Only since v5.0 does Windows PowerShell ship with `Set-Clipboard` and `Get-Clipboard` cmdlets.\n  * This module fills the gap for v2-v4, albeit only with respect to _text_.  \n  * For implementing backward-compatible functionality, you may also use this module in v5+, in which case this module's cmdlets call the built-in ones behind the scenes.\n  * On older versions, the implementation uses [Windows Forms](https://en.wikipedia.org/wiki/Windows_Forms) .NET types behind the scenes (namespace `System.Windows.Forms`)\n\n* **Use in _universal scripts_.**\n  * Universal scripts are scripts that run on both Windows PowerShell and Powershell Core, on all supported platforms, including older versions of Windows PowerShell; in this case, down to version 2.\n\n# Installation\n\n## Installation from the PowerShell Gallery\n\n**Prerequisite**: The `PowerShellGet` module must be installed (verify with `Get-Command Install-Module`).  \n`PowerShellGet` comes with PowerShell version 5 or higher; it is possible to manually install it on versions 3 and 4 - see [the docs](https://docs.microsoft.com/en-us/powershell/scripting/gallery/installing-psget).\n\n* Current-user-only installation:\n\n```powershell\n# Installation for the current user only.\nPS\u003e Install-Module ClipboardText -Scope CurrentUser\n```\n\n* All-users installation (requires elevation / `sudo`):\n\n```powershell\n# Installation for ALL users.\n# IMPORTANT: Requires an ELEVATED session:\n#   On Windows: \n#     Right-click on the Windows PowerShell icon and select \"Run as Administrator\".\n#   On Linux and macOS:\n#     Run `sudo pwsh` from an existing terminal.\nELEV-PS\u003e Install-Module ClipboardText -Scope AllUsers\n```\n\nSee also: [this repo's page in the PowerShell Gallery](https://www.powershellgallery.com/packages/ClipboardText).\n\n## Manual Installation\n\nIf you're still using PowerShell v2, manual installation is your only option.\n\nClone this repository (as a subfolder) into one of the directories listed in the `$env:PSModulePath` variable; e.g., to install the module in the context of the current user, choose the following parent folders:\n\n* **Windows**:\n  * Windows PowerShell: `$HOME\\Documents\\WindowsPowerShell\\Modules`\n  * PowerShell Core: `$HOME\\Documents\\PowerShell\\Modules`\n* **macOs, Linux** (PowerShell Core): \n  * `$HOME/.local/share/powershell/Modules`\n\nAs long as you've cloned into one of the directories listed in the `$env:PSModulePath` variable - copying to some of which requires elevation / `sudo` - and as long your `$PSModuleAutoLoadingPreference` is not set (the default) or set to `All`, calling `Set-ClipboardText` or `Get-ClipboardText` should import the module on demand - except in _PowerShell v2_.\n\nTo explicitly import the module, run `Import-Module \u003cpath/to/module-folder\u003e`.\n\n**Example**: Install as a current-user-only module:\n\nNote: Assumes that [`git`](https://git-scm.com/) is installed.\n\n```powershell\n# Switch to the parent directory of the current user's modules.\nSet-Location $(if ($env:OS -eq 'Windows_NT') { \"$HOME\\Documents\\{0}\\Modules\" -f ('WindowsPowerShell', 'PowerShell')[[bool]$IsCoreClr] } else { \"$HOME/.local/share/powershell/Modules\" })\n# Clone this repo into subdir. 'ClipboardText'; --depth 1 gets only the latest revision.\ngit clone --depth 1 --quiet https://github.com/mklement0/ClipboardText\n```\n\nOn _Windows PowerShell v2_, you must now explicitly load the module:\n\n```powershell\nImport-Module -Verbose .\\ClipboardText\n```\n\nRun `Set-ClipboardText -?` to verify that installation succeeded and that the module is loaded on demand (PSv3+):\nyou should see brief CLI help text.\n\n# Usage\n\nIn short:\n\n* `Set-ClipboardText` copies strings as-is; output from commands is copied using the same representation you see in the console, essentially obtained via `Out-String`; e.g.:\n\n```powershell\n# Copy the full path of the current filesystem location to the clipbard:\n$PWD.Path | Set-ClipboardText\n\n# Copy the names of all files in the current directory to the clipboard:\nGet-ChildItem -File -Name | Set-ClipboardText\n```\n\n* `Get-ClipboardText` retrieves text from the clipboard as an _array of lines_ by default; use `-Raw` to request the text as-is, as a potentially multi-line string.\n\n```powershell\n# Retrieve text from the clipboard as a single string and save it to a file:\nGet-ClipboardText -Raw \u003e out.txt\n\n# Retrieve text from the clipboard as an array of lines and prefix each with\n# a line number:\nGet-ClipboardText | ForEach-Object { $i=0 } { '#{0}: {1}' -f (++$i), $_ }\n```\n\nFor more, consult the **built-in help** after installation:\n\n```powershell\n# Concise command-line help with terse description and syntax diagram.\nGet-ClipboardText -?\nSet-ClipboardText -?\n\n# Full help, including parameter descriptions and details and examples.\nGet-Help -Full Get-ClipboardText\nGet-Help -Full Set-ClipboardText\n\n# Examples only\nGet-Help -Examples Get-ClipboardText\nGet-Help -Examples Set-ClipboardText\n```\n\n# License\n\nSee [LICENSE.md](./LICENSE.md).\n\n# Changelog\n\nSee [CHANGELOG.md](./CHANGELOG.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmklement0%2Fclipboardtext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmklement0%2Fclipboardtext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmklement0%2Fclipboardtext/lists"}