iTranslated by AI

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

Setting a default workspace to open in Visual Studio Code

に公開
2025/07/08

Since there's no such method, we need to improvise.

I set it up in .zshrc (or .bashrc) like this:

~/.zshrc
code() {
    if [ $# -eq 0 ]; then
        command code /path/to/your/default/workspace
    else
        command code "$@"
    fi
}
  • The command command executes the original command (in this case, code). Forgetting this will cause the function to call itself recursively indefinitely.
  • Of course, you could also make this function a script and place it in your PATH with higher priority.
  • By the way, I set the default workspace to the folder (itself a workspace[1]) where I manage workspace files using the Workspace Explorer extension. This way, I first open the list of existing workspace settings.
脚注
  1. Confusing, I know. In Workspace Explorer, I manage a folder that aggregates workspace files as a workspace itself, and I specify that workspace. ↩︎

Discussion