Gregor Martynus

Gregor Martynus

// 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);
// Shortcut: command option g
//Shortcut: command shift -
// Menu: Set GitHub Status
// Description: Sets the status text on your GitHub Profile
const message = await arg("What would you like to say?");
const token = await env("GITHUB_STATUS_TOKEN", {
secret: true,
ignoreBlur: true,
hint: md(
`Create a token [on GitHub](https://github.com/settings/tokens/new?scopes=user&description=kit%20script)`
),
});
const response = await post(
"https://api.github.com/graphql",
{
query: `mutation ($text:String) {
changeUserStatus(input:{message:$text}) {
status {
message
}
}
}`,
variables: {
text: message,
},
},
{
headers: {
authorization: `token ${token}`,
},
}
);