editprompt 0.2.1 → 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/README.md +4 -0
- package/dist/index.js +29 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ https://github.com/user-attachments/assets/01bcda7c-7771-4b33-bf5c-629812d45cc4
|
|
|
10
10
|
- 🔍 **Process Detection**: Automatically detects running CLI processes (configurable)
|
|
11
11
|
- 🖥️ **Tmux Support**: Send prompts directly to tmux sessions
|
|
12
12
|
- 📋 **Clipboard Fallback**: Automatically copies to clipboard if sending fails
|
|
13
|
+
- 📋 **Always Copy Option**: Copy to clipboard even after successful tmux delivery (`--always-copy`)
|
|
13
14
|
- ⚡ **Smart Fallbacks**: Multiple fallback strategies ensure your prompt gets delivered
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
@@ -46,6 +47,9 @@ editprompt -t %45
|
|
|
46
47
|
editprompt --env THEME=dark
|
|
47
48
|
editprompt -E THEME=dark -E LANG=ja_JP.UTF-8
|
|
48
49
|
|
|
50
|
+
# Always copy to clipboard after sending to tmux pane
|
|
51
|
+
editprompt --always-copy
|
|
52
|
+
|
|
49
53
|
# Show help
|
|
50
54
|
editprompt --help
|
|
51
55
|
|
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,28 +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
|
-
if (process$1.tmuxSession && process$1.tmuxWindow && process$1.tmuxPane) {
|
|
212
|
-
await sendToTmuxPane(process$1.tmuxSession, process$1.tmuxWindow, process$1.tmuxPane, content);
|
|
213
|
-
return;
|
|
207
|
+
await sendToTmuxPane(targetPaneId, content);
|
|
208
|
+
if (alwaysCopy) {
|
|
209
|
+
await copyToClipboard(content);
|
|
210
|
+
console.log("Copy!");
|
|
214
211
|
}
|
|
212
|
+
return;
|
|
215
213
|
} catch (error) {
|
|
216
214
|
console.log(`Failed to send to process. Content copied to clipboard. Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
217
215
|
}
|
|
@@ -271,6 +269,10 @@ await cli(argv, {
|
|
|
271
269
|
description: "Environment variables to set (e.g., KEY=VALUE)",
|
|
272
270
|
type: "string",
|
|
273
271
|
multiple: true
|
|
272
|
+
},
|
|
273
|
+
"always-copy": {
|
|
274
|
+
description: "Always copy content to clipboard, even if tmux pane is available",
|
|
275
|
+
type: "boolean"
|
|
274
276
|
}
|
|
275
277
|
},
|
|
276
278
|
async run(ctx) {
|
|
@@ -282,12 +284,10 @@ await cli(argv, {
|
|
|
282
284
|
return;
|
|
283
285
|
}
|
|
284
286
|
const targetPane = ctx.values["target-pane"];
|
|
287
|
+
const alwaysCopy = ctx.values["always-copy"];
|
|
285
288
|
if (targetPane) {
|
|
286
289
|
console.log("Sending content to specified pane...");
|
|
287
|
-
await sendContentToProcess(
|
|
288
|
-
pid: 0,
|
|
289
|
-
name: "direct-pane"
|
|
290
|
-
}, content, targetPane);
|
|
290
|
+
await sendContentToProcess(targetPane, content, alwaysCopy);
|
|
291
291
|
console.log("Content sent successfully!");
|
|
292
292
|
} else {
|
|
293
293
|
const processName = ctx.values.process || DEFAULT_PROCESS_NAME;
|
|
@@ -302,8 +302,14 @@ await cli(argv, {
|
|
|
302
302
|
if (selectedProcess.cwd) processInfo.push(`Directory: ${selectedProcess.cwd}`);
|
|
303
303
|
console.log(`Selected process: ${processInfo.join(" | ")}`);
|
|
304
304
|
console.log(`Sending content to ${processName} process...`);
|
|
305
|
-
|
|
306
|
-
|
|
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
|
+
}
|
|
307
313
|
}
|
|
308
314
|
}
|
|
309
315
|
} catch (error) {
|