Skip to content

Instantly share code, notes, and snippets.

@gr2m
Last active May 14, 2021 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gr2m/f5d7ee961664ee1e2561ca29311026c6 to your computer and use it in GitHub Desktop.
Save gr2m/f5d7ee961664ee1e2561ca29311026c6 to your computer and use it in GitHub Desktop.
// Menu: Create gist from clipboard
// Description: Creates a new GitHub Gist with the contents of your current clipboard
// Author: Gregor Martynus
// Twitter: @gr2m
// https://github.com/gr2m/scriptkit-octokit/
const { Octokit } = await npm("scriptkit-octokit");
const octokit = new Octokit({
auth: {
scopes: ["gist"],
},
});
// copy the content from the current clipboard
const content = await paste();
if (!content) {
console.log("clipboard is empty");
exit();
}
const { data } = await octokit.rest.gists.create({
description: "Created using https://github.com/johnlindquist/kit/discussions/266",
public: false,
files: {
"clipboard.txt": { content },
},
});
await copy(data.html_url);
console.log("Gist created at %s", data.html_url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment