editprompt 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +24 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import find from "find-process";
|
|
|
10
10
|
import inquirer from "inquirer";
|
|
11
11
|
|
|
12
12
|
//#region package.json
|
|
13
|
-
var version = "0.2.
|
|
13
|
+
var version = "0.2.3";
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/config/constants.ts
|
|
@@ -190,36 +190,26 @@ async function findTargetInTmux(processName = DEFAULT_PROCESS_NAME) {
|
|
|
190
190
|
}
|
|
191
191
|
return matchedProcesses;
|
|
192
192
|
}
|
|
193
|
-
async function sendToTmuxPane(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
async function sendToSpecificPane(paneId, content) {
|
|
198
|
-
const tempContent = content.replace(/'/g, "'\\''");
|
|
199
|
-
await execAsync(`printf %s '${tempContent}' | tmux load-buffer -b editprompt -`);
|
|
200
|
-
await execAsync(`tmux paste-buffer -d -t '${paneId}' -b editprompt`);
|
|
193
|
+
async function sendToTmuxPane(paneId, content) {
|
|
194
|
+
await execAsync(`tmux send-keys -t '${paneId}' '${content.replace(/'/g, "'\\''")}'`);
|
|
195
|
+
console.log(`Content sent to tmux pane: ${paneId}`);
|
|
201
196
|
}
|
|
202
197
|
async function copyToClipboard(content) {
|
|
203
198
|
await clipboardy.write(content);
|
|
204
199
|
}
|
|
205
|
-
async function sendContentToProcess(
|
|
200
|
+
async function sendContentToProcess(targetPaneId, content, alwaysCopy) {
|
|
201
|
+
if (!targetPaneId) {
|
|
202
|
+
await copyToClipboard(content);
|
|
203
|
+
console.log("Copy!");
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
206
|
try {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
console.log("Copy!");
|
|
212
|
-
}
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
if (process$1.tmuxSession && process$1.tmuxWindow && process$1.tmuxPane) {
|
|
216
|
-
await sendToTmuxPane(process$1.tmuxSession, process$1.tmuxWindow, process$1.tmuxPane, content);
|
|
217
|
-
if (alwaysCopy) {
|
|
218
|
-
await copyToClipboard(content);
|
|
219
|
-
console.log("Copy!");
|
|
220
|
-
}
|
|
221
|
-
return;
|
|
207
|
+
await sendToTmuxPane(targetPaneId, content);
|
|
208
|
+
if (alwaysCopy) {
|
|
209
|
+
await copyToClipboard(content);
|
|
210
|
+
console.log("Copy!");
|
|
222
211
|
}
|
|
212
|
+
return;
|
|
223
213
|
} catch (error) {
|
|
224
214
|
console.log(`Failed to send to process. Content copied to clipboard. Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
225
215
|
}
|
|
@@ -297,10 +287,7 @@ await cli(argv, {
|
|
|
297
287
|
const alwaysCopy = ctx.values["always-copy"];
|
|
298
288
|
if (targetPane) {
|
|
299
289
|
console.log("Sending content to specified pane...");
|
|
300
|
-
await sendContentToProcess(
|
|
301
|
-
pid: 0,
|
|
302
|
-
name: "direct-pane"
|
|
303
|
-
}, content, targetPane, alwaysCopy);
|
|
290
|
+
await sendContentToProcess(targetPane, content, alwaysCopy);
|
|
304
291
|
console.log("Content sent successfully!");
|
|
305
292
|
} else {
|
|
306
293
|
const processName = ctx.values.process || DEFAULT_PROCESS_NAME;
|
|
@@ -315,8 +302,14 @@ await cli(argv, {
|
|
|
315
302
|
if (selectedProcess.cwd) processInfo.push(`Directory: ${selectedProcess.cwd}`);
|
|
316
303
|
console.log(`Selected process: ${processInfo.join(" | ")}`);
|
|
317
304
|
console.log(`Sending content to ${processName} process...`);
|
|
318
|
-
|
|
319
|
-
|
|
305
|
+
const paneId = selectedProcess.tmuxPane;
|
|
306
|
+
if (paneId) {
|
|
307
|
+
await sendContentToProcess(paneId, content, alwaysCopy);
|
|
308
|
+
console.log("Content sent successfully!");
|
|
309
|
+
} else {
|
|
310
|
+
await copyToClipboard(content);
|
|
311
|
+
console.log("No tmux pane found. Content copied to clipboard.");
|
|
312
|
+
}
|
|
320
313
|
}
|
|
321
314
|
}
|
|
322
315
|
} catch (error) {
|