{"id":13463127,"url":"https://github.com/janlelis/clipboard","last_synced_at":"2025-05-15T08:00:22.666Z","repository":{"id":1096026,"uuid":"954189","full_name":"janlelis/clipboard","owner":"janlelis","description":"Ruby access to the clipboard on Windows, Linux, macOS, Java, WSL and more platforms 📋︎","archived":false,"fork":false,"pushed_at":"2024-04-09T06:25:18.000Z","size":238,"stargazers_count":378,"open_issues_count":4,"forks_count":35,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-12T21:47:54.663Z","etag":null,"topics":["clipboard","cygwin","java","linux","macos","osc52","ruby","wayland","windows","wsl","x11"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/janlelis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2010-10-01T13:04:32.000Z","updated_at":"2025-05-06T17:21:47.000Z","dependencies_parsed_at":"2024-05-01T10:35:10.798Z","dependency_job_id":"5f3c95d4-008c-4031-948a-6420b0d83e85","html_url":"https://github.com/janlelis/clipboard","commit_stats":{"total_commits":183,"total_committers":16,"mean_commits":11.4375,"dds":0.3224043715846995,"last_synced_commit":"ad046c6cce01975081fcb75dc935fe23afe6c0d7"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlelis%2Fclipboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlelis%2Fclipboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlelis%2Fclipboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janlelis%2Fclipboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janlelis","download_url":"https://codeload.github.com/janlelis/clipboard/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254057695,"owners_count":22007544,"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":["clipboard","cygwin","java","linux","macos","osc52","ruby","wayland","windows","wsl","x11"],"created_at":"2024-07-31T13:00:46.519Z","updated_at":"2025-05-15T08:00:21.308Z","avatar_url":"https://github.com/janlelis.png","language":"Ruby","readme":"# Clipboard Ruby Gem 📋︎ [![version](https://badge.fury.io/rb/clipboard.svg)](https://badge.fury.io/rb/clipboard) [![[ci]](https://github.com/janlelis/clipboard/workflows/Test/badge.svg)](https://github.com/janlelis/clipboard/actions?query=workflow%3ATest)\n\nLets you access the system clipboard from everywhere. Currently supported platforms:\n\n- Linux (X11)\n- Linux (Wayland)\n- MacOS\n- Windows\n- Cygwin (POSIX environment for Windows)\n- WSL (Windows Subsystem for Linux)\n- Gtk+ (Cross Platform Widget Toolkit)\n- Java (on JRuby)\n- *Experimental:* OSC52 (ANSI escape sequence) **only copying** - see note below\n\nSupported Rubies: **3.3**, **3.2**, **3.1**, **3.0**\n\nUnsupported, but might still work: **2.X** (use clipboard gem version 1.x)\n\n## Usage\n\n* `Clipboard.copy` - Copies a string to system clipboard\n* `Clipboard.paste` - Paste text contents from system clipboard as string\n* `Clipboard.clear` - Empties the system clipboard\n\n## Setup\n\nRun `gem install clipboard` (and `gem install ffi` on Windows) or add the following lines to your `Gemfile`:\n\n```ruby\ngem \"clipboard\"\ngem \"ffi\", :platforms =\u003e [:mswin, :mingw] # Necessary on Windows\n```\n\n**Important note for Linux** users: The clipboard gem requires additional programs to be available:\n\n- On X11: **xsel** or **xclip**\n- On Wayland: **wl-copy** and **wl-paste** (wl-clipboard) - depending on your system, just having **xsel** / **xclip** might also work\n\n\n## Clipboard Implementations\n\nIn most environments, the appropriate clipboard implementation can be detected automatically. If none is found, the gem will fallback to a file based one, which will just write to/read from `~/.clipboard` instead of the system clipboard.\n\nYou can check the implementation used with `Clipboard.implementation` or set a specific implementation with `Clipboard.implementation = ...`\n\n### Alternative Clipboard Providers\n\nThere are more implementations included in this gem, which are not activated by default. You can opt-in to use them if you think they are a better fit for your application environment:\n\n#### Java\n\nActivate with: `Clipboard.implementation = :java`\n\nThis is an option for [JRuby users](https://www.jruby.org/) which will use the clipboard functionality from the Java standard library.\n\n#### GTK+\n\nActivate with: `Clipboard.implementation = :gtk`\n\nThis utilizes the **GTK+** library. See [Ruby-GNOME2](https://github.com/ruby-gnome2/ruby-gnome2#ruby-gnome2) for more info.\n\nRequires the `gtk3` or `gtk2` gem to be installed.\n\n#### OSC52\n\nActivate with: `Clipboard.implementation = :osc52`\n\nOSC52 is an ANSI escape sequence that some terminals support to access the system clipboard. One advantage of using this clipboard provider is that it is possible to copy from remote ssh sessions to your system clipboard.\n\nAs of the current version, only **copy** and **clear** commands are supported (no **paste**).\n\n**Please note**: Even if your terminal includes OSC52 functionality, the feature could be (partially) disabled to prevent malicious scripts from accessing (or setting) your clipboard.\n\n## Tips \u0026 Tricks\n\n### Linux: Using Clipboard via SSH\n\nTo be able to use the clipboard through SSH (using the `xsel`/`xclip` based implementation), you need to install `xauth` on your server and connect via `ssh -X` or `ssh -Y`. Please note that some server settings restrict this feature.\n\n### Linux: Copy To or Paste From Specific Clipboard / Selection\n\nThe clipboard on Linux is divided into multiple clipboard selections. You can choose from which clipboard you want to `paste` from by passing it as the first argument. The default is *:clipboard*, other options are *:primary* and, for some implementations, *:secondary*:\n\n```ruby\nClipboard.paste(\"primary\") # or\nClipboard.paste(clipboard: \"primary\")\n```\n\n`Clipboard.copy` will copy to all available clipboards, except if you specifiy a clipboard using the `clipboard:` keyword argument:\n\n```ruby\nClipboard.copy(\"only goes to primary clipboard\", clipboard: \"primary\")\n```\n\n### Windows: Encoding Info\n\nWindows uses [UTF-16LE](https://en.wikipedia.org/wiki/UTF-16) as its default encoding, so pasted strings will always come in UTF-16. You can then manually convert them to your desired encoding, for example, UTF-8, using the [String#encode](https://rubyapi.org/o/string#method-i-encode) method:\n\n```ruby\nClipboard.paste.encode('UTF-8')\n```\n\n### CLI Utility: blip\n\nThe [blip gem](https://rubygems.org/gems/blip) is a handy command-line wrapper for the clipboard gem. It lets you quickly copy a file's content to your clipboard:\n\n```\n$ blip FILE_NAME\n```\n\nWithout any arguments, it will just paste the contents of the clipboard.\n\n## MIT\n\nCopyright (c) 2010-2024 Jan Lelis \u003chttps://janlelis.com\u003e released under the MIT license. Contributions by and thanks to [Michael Grosser and all the other contributors!](https://github.com/janlelis/clipboard/graphs/contributors)\n","funding_links":[],"categories":["Developer Tools","Ruby","IRB"],"sub_categories":["irb Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanlelis%2Fclipboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanlelis%2Fclipboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanlelis%2Fclipboard/lists"}