https://github.com/jayjun/clipboard
An Elixir package to copy and paste from system clipboard
https://github.com/jayjun/clipboard
hacktoberfest
Last synced: 5 months ago
JSON representation
An Elixir package to copy and paste from system clipboard
- Host: GitHub
- URL: https://github.com/jayjun/clipboard
- Owner: jayjun
- License: mit
- Created: 2017-07-06T08:18:29.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-09-18T14:22:19.000Z (almost 4 years ago)
- Last Synced: 2025-11-01T08:14:19.855Z (8 months ago)
- Topics: hacktoberfest
- Language: Elixir
- Homepage:
- Size: 12.7 KB
- Stars: 35
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Clipboard

Copy and paste from system clipboard.
Sick of `IO.puts(json)` then manually selecting your terminal? Try `Clipboard.copy(json)`!
Wraps ports to system-specific utilities responsible for clipboard access. It uses the default
clipboard utilities on macOS, Linux and Windows but can be configured to call any executable.
## Examples
```elixir
Clipboard.copy("Hello, World!") # Copied to clipboard
"Hello, World!"
|> Clipboard.copy() # Insert into pipelines
|> business_as_usual()
# And paste too!
greeting = Clipboard.paste()
```
## Options
Clipboard uses these utilities by default.
| OS | Utilities |
| ------- | -------------------- |
| macOS | `pbcopy` & `pbpaste` |
| Linux | `xclip` |
| Windows | `clip` |
However, you can instruct Clipboard to use another command by setting `config.exs`.
```elixir
config :clipboard,
unix: [
copy: {"xsel", ["-i"]},
paste: {"xsel", ["-o"]}
]
```
Supported operating systems are `:macos`, `:unix` and `:windows`.
## Installation
Add `clipboard` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:clipboard, ">= 0.0.0", only: [:dev]}
]
end
```
Don’t forget to update your dependencies.
```
$ mix deps.get
```
## Caveats
Pasting on Windows doesn’t work out of the box because `clip` only supports copying.
## Links
- [Documentation][1]
- [Hex][2]
## License
Clipboard is released under [MIT][3] license.
[1]: https://hexdocs.pm/clipboard/Clipboard.html
[2]: https://hex.pm/packages/clipboard
[3]: https://github.com/jayjun/clipboard/blob/master/LICENSE.md