-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstant_yield.ts
More file actions
40 lines (32 loc) · 1.04 KB
/
instant_yield.ts
File metadata and controls
40 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @license
* Copyright 2026 Steven A. Thompson
* SPDX-License-Identifier: MIT
*/
import { execSync } from 'child_process';
import { SESSION_NAME } from './tmux_utils.js';
async function main() {
const args = process.argv.slice(2);
// const id = args[0] || '????'; // ID unused in force mode
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
// Minimal delay to ensure detached process logic settles, but effectively immediate.
await delay(50);
try {
const target = `${SESSION_NAME}:0.0`;
// 0. Send Escape a few times to clear any partial input or modes
execSync(`tmux send-keys -t ${target} Escape`);
await delay(100);
execSync(`tmux send-keys -t ${target} Escape`);
await delay(100);
// 1. Send C-c immediately
execSync(`tmux send-keys -t ${target} C-c`);
await delay(100);
// 2. Send Enters
execSync(`tmux send-keys -t ${target} Enter`);
await delay(100);
execSync(`tmux send-keys -t ${target} Enter`);
} catch (error) {
process.exit(1);
}
}
main();