From 4b8b62d7e106c856d6e5b5399a46f6fb5008b85c Mon Sep 17 00:00:00 2001 From: Anirudh Gupta <146579014+AnirudhG07@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:21:27 +0530 Subject: [PATCH] docs: add `ya.clipboard` to utils (#101) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 三咲雅 · Misaki Masa --- docs/plugins/utils.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/plugins/utils.md b/docs/plugins/utils.md index 839888c5..971df193 100644 --- a/docs/plugins/utils.md +++ b/docs/plugins/utils.md @@ -306,6 +306,22 @@ This function is only available on Unix-like systems. Only available on Unix-like systems. Returns the hostname of the current machine, which is a string if successful; otherwise, `nil`. +### `clipboard(text)` {#ya.clipboard} + +Get or set the content of the system clipboard. + +- `text` - Optional, value to be set, which is a string. If not provided, the content of the clipboard will be returned. + +```lua +-- Get contents from the clipboard +local content = ya.clipboard() + +-- Set contents to the clipboard +ya.clipboard("new content") +``` + +This function is only available in the async context. + ## ps {#ps} Yazi's DDS (Data Distribution Service) uses a Lua-based publish-subscribe model as its carrier. That is, you can achieve cross-instance communication and state persistence through the `ps` API. See [DDS](/docs/dds) for details.