One-Click Open VSCode Projects with Alfred

Jan 23, 2025 · 1 min read · 139 Words · -Views -Comments · Programming
Alfred Vscode Cursor Workflow 🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

Cursor(VSCode) has been used frequently for coding, but opening projects is inefficient. I wanted to create an Alfred Workflow for a one-click VSCode project opening. Research showed that VSCode stores recently opened projects, making this technically feasible.

Screenshots

https://github.com/alanhe421/alfred-workflows/blob/master/vscode-open-project/screenshots/screenshot1.gif?raw=true

Download: VSCode-Open Project

Implementation Approach

Database Access

VSCode/Cursor stores recent file/folder history in:

  • VSCode $HOME/Library/Application\ Support/Code/User/globalStorage/state.vscdb

  • Cursor $HOME/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb

Note: Application Support contains spaces, requiring \ escaping in the command line.

Database Query

Use Ruby to query and extract recent project paths from history.recentlyOpenedPathsList in ItemTable, parsing JSON data with jq.

  1. Mac has SQLite pre-installed for direct use.

Alfred Format Output

With data extracted, the output follows the Alfred Script Filter format.

Open VSCode/Cursor

Multiple methods:

  1. URL Scheme
  2. Command line (vscode, cursor)

URL Scheme was used, and both VSCode and Cursor support it.

Conclusion

This workflow significantly simplifies opening VSCode/Cursor projects.

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover