One-Click Open VSCode Projects with Alfred

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.