iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🗂

Instantly Launch VS Code Projects with Raycast for Mac

に公開

What is Raycast?

Raycast is a launcher tool available for Mac.
When it comes to launchers, there's the standard Spotlight and its competitor Alfred, but Raycast is more feature-rich than Spotlight and offers many features for free that are only available in Alfred's paid version. It's a fantastic tool, to say the least.

I won't go too deep into Raycast itself here. If you want to know about the installation method or detailed features, please refer to the following articles.
https://zenn.dev/fumi_sagawa/articles/2ff5fd9c03fbcd
https://zenn.dev/yum3/articles/i_raycast_or_alfred

I Want to Open VS Code with Raycast!

VS Code boasts such a high market share that many people probably use it every single day.
How do you open a specific project (directory) in VS Code?

  • Move to the directory in the terminal and run code .?
  • Drag and drop the directory you want to open into the VS Code window?

Both are reasonably smart, but they involve multiple steps, which can be a bit tedious if you open them frequently. That's why you'll want to "open a specific project with Raycast!" (Right?)
Raycast is a launcher app, so of course it can launch the installed VS Code, but it cannot open specific projects by default. This is where extensions come in.
This article describes how to set up Raycast and its extensions to open specific projects in VS Code.
You'll need to do a bit of setup at first, but once you've set it up, you'll be able to open them easily in your daily work!

Before You Begin

Prerequisites

We will start with the following preparations completed:

  • VS Code is installed
  • Raycast is installed

Overall Flow

The process consists of roughly 4 steps:

  1. Install the extension in Raycast
  2. Install the "Project Manager" extension in VS Code
  3. Register projects with "Project Manager"
  4. Launch!

Let's Try It

1. Install the Extension in Raycast

Open Raycast's Preference and click Extensions+Install From Store.

Type "vscode" in the search box. Select Visual Studio Code - Project Manager and press Command + Enter to install.

Close Preference and launch Raycast (default Hotkey is Option + Space).
If you type vscode and Visual Studio Code - Project Manager appears in the candidates, the installation is complete.

However, even if you select Visual Studio Code - Project Manager, no projects will be displayed.
This is because Raycast does not recognize "which directories are projects."
To solve this, we will next register the projects on the VS Code side.

2. Install "Project Manager" Extension in VS Code

Launch VS Code.
Open the Extensions menu, type project manager in the search box, and install the Project Manager extension.

3. Registering Projects with "Project Manager"

Open the directory you want to open as a project in VS Code using code . or drag-and-drop.
In this example, I'll use zenn-content, the directory (repository) where I manage my Zenn content.
Press Command + Shift + P to open the command palette.
Type save project and select Project Manager: Save Project.

Enter a project name. It defaults to the directory name, but you can leave it as is or change it.

Once you've entered the project name, press Enter to register. If "Project saved!" appears, you're all set.

Repeat step 3 for each directory you want to open as a project in Raycast.

4. Launch!

Launch Raycast (default Hotkey is Option + Space).
Select Visual Studio Code - Project Manager.

The projects registered in step 3 will be displayed, so select the project you want to open and press Enter.

The selected project has been opened!

Bonus: Deleting Projects

As you register more projects, usability may decrease, so it's a good idea to remove projects that are no longer used frequently.

Open the command palette in VS Code (Command + Shift + P).
Type edit project and select Project Manager: Edit Projects.

The projects.json file will open. As you can see from this, you can edit your registered projects by modifying this file.
Simply delete the block for the project you want to remove and save the projects.json file to complete the deletion.

Have a great Mac life, everyone!

GitHubで編集を提案

Discussion