From 0a99eda5ec33258d57a716eb2285886bc0d972f9 Mon Sep 17 00:00:00 2001 From: James Murdza Date: Thu, 5 Sep 2024 15:12:29 -0700 Subject: [PATCH] chore: split up default terminal commands --- backend/server/src/index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index 09ad464..f66553c 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -531,9 +531,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);