Last active
September 13, 2024 15:06
-
-
Save gr2m/f5d7ee961664ee1e2561ca29311026c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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