diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index cec9104..18078e7 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -526,9 +526,15 @@ io.on("connection", async (socket) => { rows: 20, //onExit: () => console.log("Terminal exited", id), }); - await terminals[id].sendData( - `cd "${path.join(dirName, "projects", data.sandboxId)}"\rexport PS1='user> '\rclear\r` - ); + + const defaultDirectory = path.join(dirName, "projects", data.sandboxId); + const defaultCommands = [ + `cd "${defaultDirectory}"`, + "export PS1='user> '", + "clear" + ] + for (const command of defaultCommands) await terminals[id].sendData(command + "\r"); + console.log("Created terminal", id); } catch (e: any) { console.error(`Error creating terminal ${id}:`, e);