Use the Clipboard APIs to work with content from your clipboard. You can write contents to the clipboard through Clipboard.copy and clear it through Clipboard.clear. The Clipboard.paste function inserts text at the current cursor position in your frontmost app.
The action Action.CopyToClipboard can be used to copy content of a selected list item to the clipboard and the action Action.Paste can be used to insert text in your frontmost app.
Copies text or a file to the clipboard.
A Promise that resolves when the content is copied to the clipboard.
Pastes text or a file to the current selection of the frontmost application.
A Promise that resolves when the content is pasted.
Clears the current clipboard contents.
A Promise that resolves when the clipboard is cleared.
Reads the clipboard content as plain text, file name, or HTML.
A promise that resolves when the clipboard content was read as plain text, file name, or HTML.
Reads the clipboard as plain text.
A promise that resolves once the clipboard content is read as plain text.
Type of content that is copied and pasted to and from the Clipboard
Type of content that is read from the Clipboard
Type of options passed to Clipboard.copy.
content*
The content to copy to the clipboard.
string or number or Clipboard.Content
options
Options for the copy operation.
content*
The content to insert at the cursor.
string or number or Clipboard.Content
options
Options for the read operation.
Object
options.offset
Specify an offset to access the Clipboard History. Minimum value is 0, maximum value is 5.
number
options
Options for the readText operation.
Object
options.offset
Specify an offset to access the Clipboard History. Minimum value is 0, maximum value is 5.
number
concealed
Indicates whether the content be treated as confidential. If true, it will not be recorded in the Clipboard History.
boolean
async function copy(content: string | number | Content, options?: CopyOptions): Promise<void>;import { Clipboard } from "@raycast/api";
export default async function Command() {
// copy some text
await Clipboard.copy("https://raycast.com");
const textContent: Clipboard.Content = {
text: "https://raycast.com",
};
await Clipboard.copy(textContent);
// copy a file
const file = "/path/to/file.pdf";
try {
const fileContent: Clipboard.Content = { file };
await Clipboard.copy(fileContent);
} catch (error) {
console.log(`Could not copy file '${file}'. Reason: ${error}`);
}
// copy confidential data
await Clipboard.copy("my-secret-password", { concealed: true });
}async function paste(content: string | Content): Promise<void>;import { Clipboard } from "@raycast/api";
export default async function Command() {
await Clipboard.paste("I really like Raycast's API");
}async function clear(): Promise<void>;import { Clipboard } from "@raycast/api";
export default async function Command() {
await Clipboard.clear();
}async function read(options?: { offset?: number }): Promise<ReadContent>;import { Clipboard } from "@raycast/api";
export default async () => {
const { text, file, html } = await Clipboard.read();
console.log(text);
console.log(file);
console.log(html);
};async function readText(options?: { offset?: number }): Promise<string | undefined>;import { Clipboard } from "@raycast/api";
export default async function Command() {
const text = await Clipboard.readText();
console.log(text);
}type Content =
| {
text: string;
}
| {
file: PathLike;
}
| {
html: string;
text?: string; // The alternative text representation of the content.
};type Content =
| {
text: string;
}
| {
file?: string;
}
| {
html?: string;
};