List and Launch Dev Projects with Script Kit

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated 2 years ago

Developers often keep their dev projects in a specific directory like "dev", "projects", or something similar. Script Kit allows you quickly read all the files of any directory then display them in a list so you can open them in your editor.

Install open-project

// Name: Open Project

import "@johnlindquist/kit"

let dirs = await readdir(home("dev"))

let selectedDir = await arg(
  "Open Project:",
  dirs.map(dir => ({
    name: dir,
    description: home("dev", dir),
    value: home("dev", dir),
  }))
)

edit(selectedDir)

John Lindquist: [0:00] Create a script called open project. We'll hit Enter. That launches the script in VS Code. I keep all of my projects in a directory called home inside of the dev folder. If you look at home dev, you'll see that, we'll run this real quick, it resolves to users John Lindquist/div.

[0:20] We'll go ahead and read that directory and find all of the directories inside of there. Let's pop those directories into an arg. We'll call this open project, then pass in our ders. Then run open project again. You can see a list of the projects I currently have in my dev directory.

[0:44] I can obviously type in filter down to select the project that I want. To provide a bit more information, we can map on this so that the choice is an object with a name of der and a description of home dev der.

[1:01] That way, when we run this, you'll see the full path beneath that, which would definitely help if we're scanning multiple directories. We're also going to add the value here. If you don't add the value, it'll pass back the entire object.

[1:15] We will add the value of that home dev der so that once you hit Enter, the value that comes out of our would be the selected der. Then we just have to pass selected der into edit. We'll say, edit selected der. It's saved there, and open project.

[1:33] We'll go ahead and open electron builder. You can see it fires open my selected editor with the directory we selected.

egghead
egghead
~ an hour ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today