kyoyoung keum

kyoyoung keum

import "@johnlindquist/kit";
// Menu: Open Chrome Bookmark
// Description: List Chrome Bookmarks. Then open tab.
// Author: kyo young
// GitHub: @youngkyo0504
let rawBookmarks = await readFile(
home("Library/Application Support/Google/Chrome/Default/Bookmarks"),
"utf8"
);
const parsedBookmarks = JSON.parse(rawBookmarks);
const bookmarkStructure = parsedBookmarks.roots.bookmark_bar.children;
const bookmarks = (function flatten(
bookmarkElements
) {
return bookmarkElements.reduce((acc, cur) => {
if (cur.type === "folder") {
return [...acc, ...flatten(cur.children)];
}
return [...acc, cur];
}, []);
})(bookmarkStructure);
let bookmarkChoices = bookmarks.map(({ name, url }) => {
return {
name: name,
description: url,
value: url,
};
});
let bookmarksAndOpen = [...bookmarkChoices];
let choices = _.uniqBy(bookmarksAndOpen, "name");
let url = await arg("Oepn Chrome tab:", choices);
focusTab(url);

// Name: Port kill
// Description: Enter port number to kill process listening on port.
// Author: kyo young
// GitHub: @youngkyo0504
import '@johnlindquist/kit';
const killPort = await npm('kill-port');
const port = await arg('Enter port to kill')
const containerClassName = 'flex justify-center items-center text-4xl h-full'
try {
await killPort(port, 'tcp')
await div(`🤖 listening on port ${port} has been killed.`,containerClassName);
} catch (error) {
console.error(error);
await div(`
🛰️ ${error.message}
`,containerClassName)
}