Scripts by gr2m

Create Gist from Clipboard

Install create-gist-from-clipboard

// 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);

I highly recommend setting a shortcut, e.g. add to the top:

// Shortcut: command option g
Discuss Post

Set GitHub profile status

Install set-github-status

//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}`,
},
}
);
Discuss Post

Copy GitHub name

install

// Menu: Copy GitHub user name
// Description: Copies a GitHub user's first name, fallback to @login
// Author: Gregor Martynus
// Twitter: @gr2m
const { Octokit } = await npm("octokit");
const { createOAuthDeviceAuth } = await npm("@octokit/auth-oauth-device");
// set GitHub Token unless it's already set
let octokit;
if (env.GITHUB_TOKEN_NO_SCOPES) {
octokit = new Octokit({
auth: env.GITHUB_TOKEN_NO_SCOPES,
});
} else {
const auth = createOAuthDeviceAuth({
clientType: "oauth-app",
clientId: "34e4eac44e03b0daa82b",
onVerification(verification) {
copy(verification.user_code);
arg({
placeholder: `Press <enter> after granting permissions`,
ignoreBlur: true,
hint: `
Open <a href="${verification.verification_uri}">${verification.verification_uri}</a>, paste code from clipboard
`,
});
},
});
const { token } = await auth({
type: "oauth",
});
octokit = new Octokit({
auth: token,
});
await cli("set-env-var", "GITHUB_TOKEN_NO_SCOPES", token);
}
const { data: me } = await octokit.rest.users.getAuthenticated();
const username = await arg("Enter a GitHub username:");
let { data: user } = await octokit.rest.users.getByUsername({ username });
const userFirstNameOrUsername = user.name.trim()
? user.name.trim().split(/\s+/)[0]
: `@${user.login}`;
copy(userFirstNameOrUsername);
setPlaceholder(`"${userFirstNameOrUsername}" copied to your clipboard`);
setIgnoreBlur(false);
setHint(`Press esc to close this prompt`);

PS: I tried to publish via the built-in publish feature, but it doesn't work for me: https://github.com/johnlindquist/kit/issues/219. I created the install link above manually based on your link here: https://github.com/johnlindquist/kit/discussions/217

Discuss Post