ec10aa07422db5f4254c4b017acbfa0f7b016347

Author
TheEdgeOfRage <git@theedgeofrage.com>
Committer
TheEdgeOfRage <git@theedgeofrage.com>
Date

Message

Add option to not open shell tab in herdr workspace

Diff

 1diff --git a/dot_local/bin/executable_herdr-new-pi-workspace b/dot_local/bin/executable_herdr-new-pi-workspace
 2index 9247992ff20342e3ceb027e6f97ea540706aab5f..f17b8b87c2555b7db5309a4ebd38331381ef8fe6 100644
 3--- a/dot_local/bin/executable_herdr-new-pi-workspace
 4+++ b/dot_local/bin/executable_herdr-new-pi-workspace
 5@@ -184,6 +184,23 @@ async function chooseWorkspaceName(directory) {
 6   return workspaceName || defaultName;
 7 }
 8 
 9+async function chooseShellTab() {
10+  for (;;) {
11+    const answer = (
12+      await textPrompt().question("Open shell tab? [y/N]: ")
13+    ).trim().toLowerCase();
14+
15+    if (!answer || answer === "n" || answer === "no") {
16+      return false;
17+    }
18+    if (answer === "y" || answer === "yes") {
19+      return true;
20+    }
21+
22+    console.error("Enter y or n.");
23+  }
24+}
25+
26 function parseWorkspaceCreated(output) {
27   let response;
28   try {
29@@ -259,10 +276,7 @@ async function main() {
30     }
31 
32     const workspaceName = await chooseWorkspaceName(directory);
33-    if (!workspaceName) {
34-      console.log("Cancelled.");
35-      return;
36-    }
37+    const openShellTab = await chooseShellTab();
38 
39     const creation = parseWorkspaceCreated(
40       run(herdr, [
41@@ -279,17 +293,19 @@ async function main() {
42 
43     run(herdr, ["tab", "rename", creation.tabId, "pi"]);
44 
45-    run(herdr, [
46-      "tab",
47-      "create",
48-      "--workspace",
49-      creation.workspaceId,
50-      "--cwd",
51-      directory,
52-      "--label",
53-      "shell",
54-      "--no-focus",
55-    ]);
56+    if (openShellTab) {
57+      run(herdr, [
58+        "tab",
59+        "create",
60+        "--workspace",
61+        creation.workspaceId,
62+        "--cwd",
63+        directory,
64+        "--label",
65+        "shell",
66+        "--no-focus",
67+      ]);
68+    }
69 
70     const agentName = `pi-${Date.now().toString(36)}-${randomBytes(3).toString("hex")}`;
71     startAgentInBackground(herdr, agentName, creation.paneId);