Is there a way to launch and default open a particular folder as a workspace?

I have been SOL trying to figure out how to open a particular directory on “launch”. I tried on stack overflow but got no help :expressionless: https://stackoverflow.com/questions/59774219/how-to-open-a-default-folder-when-launching-visual-studio-code-on-newly-provisio

[original thread by Sean Cavanaugh]

[Sean Cavanaugh]

I think this was also an issue and we got pointed to work on this over here: https://github.com/eclipse-theia/theia/issues/2005#issuecomment-575600573

Hi @ipvsean . There are probably cleaner ways, but I have a couple of suggestions:

  1. provide a workspace folder as part of Theia app backend start. e.g. “yarn theia start --port=1234 /path/to/workspace-folder”. This provides a default workspace that will be used when you first connect to your app. After the first time, the last used workspace opened will override this value and be used
  1. Your application will have a config folder in the user’s home directory, by default ~/.theia/. In there file “recentworkspace.json” is created/updated each time a workspace is opened in your app. When this file exists, the latest entry will have precedence over the default workspace in 1) above, and be used as workspace next time a client connects. I guess if you deploy in a container, you could yourself create this file and add an entry for the workspace you’d like to open next time. If there is more than one entry, the most recent is default, and the others are accessible as options from the “file->open recent workspace” menu entry
  1. you could probably override default behaviors above and e.g. hardcode a default workspace that will be used instead of re-using the latest one. e.g. /home/workspace, and have that populated with whatever content a specific user needs. You would need to write your own Theia extension to do this I think