@termwire/tmux 0.6.0 → 0.7.0
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/CHANGELOG.md +6 -0
- package/dist/create-tmux.d.ts +5 -0
- package/dist/create-tmux.js +6 -1
- package/dist/hook.js +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/key.d.ts +20 -0
- package/dist/key.js +43 -0
- package/dist/session.d.ts +2 -0
- package/dist/session.js +10 -0
- package/package.json +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @termwire/tmux
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 59dbb4d: Option+click on a path in any workspace pane opens it in the workspace Neovim at that line. Turn it on with `termwire install --mouse` or `"mouse": { "openPath": "M-MouseDown1Pane" }` in the global config; `up` installs the tmux binding. The tmux adapter gains `listKeys`, `bindKey`, `unbindKey` and `setSessionOption`.
|
|
8
|
+
|
|
3
9
|
## 0.6.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/create-tmux.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { setHook, showHooks, unsetHook } from "./hook.js";
|
|
2
|
+
import { bindKey, unbindKey } from "./key.js";
|
|
2
3
|
import { respawnPane, sendKeys, splitPane } from "./pane.js";
|
|
3
4
|
import { type Exec } from "./process.js";
|
|
4
5
|
import { newSession } from "./session.js";
|
|
@@ -14,6 +15,7 @@ export declare function createTmux({ exec, env }?: CreateTmuxOptions): {
|
|
|
14
15
|
newSession: (options: Parameters<typeof newSession>[1]) => Promise<import("./command.js").WindowPaneIds>;
|
|
15
16
|
newWindow: (options: Parameters<typeof newWindow>[1]) => Promise<import("./command.js").WindowPaneIds>;
|
|
16
17
|
setEnvironment: (session: string, key: string, value: string) => Promise<void>;
|
|
18
|
+
setSessionOption: (session: string, name: string, value: string) => Promise<void>;
|
|
17
19
|
setSessionTitle: (session: string) => Promise<void>;
|
|
18
20
|
killSession: (session: string) => Promise<void>;
|
|
19
21
|
respawnPane: (options: Parameters<typeof respawnPane>[1]) => Promise<void>;
|
|
@@ -26,4 +28,7 @@ export declare function createTmux({ exec, env }?: CreateTmuxOptions): {
|
|
|
26
28
|
showHooks: (options?: Parameters<typeof showHooks>[1]) => Promise<import("./hook.js").HookEntry[]>;
|
|
27
29
|
setHook: (options: Parameters<typeof setHook>[1]) => Promise<void>;
|
|
28
30
|
unsetHook: (options: Parameters<typeof unsetHook>[1]) => Promise<void>;
|
|
31
|
+
listKeys: (table: string) => Promise<import("./key.js").KeyBinding[]>;
|
|
32
|
+
bindKey: (options: Parameters<typeof bindKey>[1]) => Promise<void>;
|
|
33
|
+
unbindKey: (options: Parameters<typeof unbindKey>[1]) => Promise<void>;
|
|
29
34
|
};
|
package/dist/create-tmux.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { attach } from "./client.js";
|
|
2
2
|
import { setHook, showHooks, unsetHook } from "./hook.js";
|
|
3
|
+
import { bindKey, listKeys, unbindKey } from "./key.js";
|
|
3
4
|
import { respawnPane, selectPane, sendKeys, splitPane } from "./pane.js";
|
|
4
5
|
import { spawnExec } from "./process.js";
|
|
5
|
-
import { hasSession, killSession, listSessions, newSession, setEnvironment, setSessionTitle, showEnvironment, } from "./session.js";
|
|
6
|
+
import { hasSession, killSession, listSessions, newSession, setEnvironment, setSessionOption, setSessionTitle, showEnvironment, } from "./session.js";
|
|
6
7
|
import { newWindow, selectLayout, selectWindow } from "./window.js";
|
|
7
8
|
export function createTmux({ exec = spawnExec, env = process.env } = {}) {
|
|
8
9
|
return {
|
|
@@ -12,6 +13,7 @@ export function createTmux({ exec = spawnExec, env = process.env } = {}) {
|
|
|
12
13
|
newSession: (options) => newSession(exec, options),
|
|
13
14
|
newWindow: (options) => newWindow(exec, options),
|
|
14
15
|
setEnvironment: (session, key, value) => setEnvironment(exec, session, key, value),
|
|
16
|
+
setSessionOption: (session, name, value) => setSessionOption(exec, session, name, value),
|
|
15
17
|
setSessionTitle: (session) => setSessionTitle(exec, session),
|
|
16
18
|
killSession: (session) => killSession(exec, session),
|
|
17
19
|
respawnPane: (options) => respawnPane(exec, options),
|
|
@@ -24,5 +26,8 @@ export function createTmux({ exec = spawnExec, env = process.env } = {}) {
|
|
|
24
26
|
showHooks: (options) => showHooks(exec, options),
|
|
25
27
|
setHook: (options) => setHook(exec, options),
|
|
26
28
|
unsetHook: (options) => unsetHook(exec, options),
|
|
29
|
+
listKeys: (table) => listKeys(exec, table),
|
|
30
|
+
bindKey: (options) => bindKey(exec, options),
|
|
31
|
+
unbindKey: (options) => unbindKey(exec, options),
|
|
27
32
|
};
|
|
28
33
|
}
|
package/dist/hook.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CommandError, execute } from "./process.js";
|
|
2
2
|
import { assertNotEmpty } from "./validation.js";
|
|
3
|
+
/** `show-hooks` prints an array hook as `name[index]` and a plain one as `name`. */
|
|
4
|
+
const hookKey = /^([A-Za-z0-9_-]+)(?:\[(\d+)\])?$/;
|
|
3
5
|
export function parseHooks(stdout) {
|
|
4
6
|
const entries = [];
|
|
5
7
|
for (const line of stdout.split("\n")) {
|
|
@@ -9,7 +11,7 @@ export function parseHooks(stdout) {
|
|
|
9
11
|
const separator = trimmed.indexOf(" ");
|
|
10
12
|
const key = separator === -1 ? trimmed : trimmed.slice(0, separator);
|
|
11
13
|
const command = separator === -1 ? "" : trimmed.slice(separator + 1);
|
|
12
|
-
const parsed =
|
|
14
|
+
const parsed = hookKey.exec(key);
|
|
13
15
|
if (!parsed)
|
|
14
16
|
continue;
|
|
15
17
|
const index = parsed[2];
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type { WindowPaneIds } from "./command.js";
|
|
|
2
2
|
export type { CreateTmuxOptions } from "./create-tmux.js";
|
|
3
3
|
export { createTmux } from "./create-tmux.js";
|
|
4
4
|
export type { HookEntry, SetHookOptions, ShowHooksOptions, UnsetHookOptions } from "./hook.js";
|
|
5
|
+
export type { BindKeyOptions, KeyBinding, UnbindKeyOptions } from "./key.js";
|
|
5
6
|
export type { RespawnPaneOptions, SplitPaneOptions } from "./pane.js";
|
|
6
7
|
export type { Exec, ExecOptions, ExecResult } from "./process.js";
|
|
7
8
|
export { CommandError } from "./process.js";
|
package/dist/key.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Exec } from "./process.js";
|
|
2
|
+
export interface KeyBinding {
|
|
3
|
+
key: string;
|
|
4
|
+
/** The command as `list-keys` prints it, re-quoted by tmux. */
|
|
5
|
+
command: string;
|
|
6
|
+
}
|
|
7
|
+
export interface BindKeyOptions {
|
|
8
|
+
table: string;
|
|
9
|
+
key: string;
|
|
10
|
+
/** One tmux command and its arguments, passed as argv so tmux never re-parses them. */
|
|
11
|
+
command: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export interface UnbindKeyOptions {
|
|
14
|
+
table: string;
|
|
15
|
+
key: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function parseKeys(stdout: string): KeyBinding[];
|
|
18
|
+
export declare function listKeys(exec: Exec, table: string): Promise<KeyBinding[]>;
|
|
19
|
+
export declare function bindKey(exec: Exec, options: BindKeyOptions): Promise<void>;
|
|
20
|
+
export declare function unbindKey(exec: Exec, options: UnbindKeyOptions): Promise<void>;
|
package/dist/key.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CommandError, execute } from "./process.js";
|
|
2
|
+
import { assertNotEmpty, ValidationError } from "./validation.js";
|
|
3
|
+
/** `list-keys` prints `bind-key [-r] -T <table> <key> <command>`, padded for alignment. */
|
|
4
|
+
const bindingLine = /^bind-key\s+(?:-r\s+)?-T\s+\S+\s+(\S+)\s+(.*)$/;
|
|
5
|
+
export function parseKeys(stdout) {
|
|
6
|
+
const bindings = [];
|
|
7
|
+
for (const line of stdout.split("\n")) {
|
|
8
|
+
const parsed = bindingLine.exec(line.trim());
|
|
9
|
+
if (parsed)
|
|
10
|
+
bindings.push({ key: parsed[1], command: parsed[2] });
|
|
11
|
+
}
|
|
12
|
+
return bindings;
|
|
13
|
+
}
|
|
14
|
+
export async function listKeys(exec, table) {
|
|
15
|
+
assertNotEmpty("table", table);
|
|
16
|
+
const command = ["tmux", "list-keys", "-T", table];
|
|
17
|
+
const execution = await execute(exec, command);
|
|
18
|
+
if (execution.exitCode !== 0) {
|
|
19
|
+
throw CommandError.from(command, execution);
|
|
20
|
+
}
|
|
21
|
+
return parseKeys(execution.stdout);
|
|
22
|
+
}
|
|
23
|
+
export async function bindKey(exec, options) {
|
|
24
|
+
assertNotEmpty("table", options.table);
|
|
25
|
+
assertNotEmpty("key", options.key);
|
|
26
|
+
if (options.command.length === 0) {
|
|
27
|
+
throw new ValidationError("command", "command must not be empty");
|
|
28
|
+
}
|
|
29
|
+
const command = ["tmux", "bind-key", "-T", options.table, options.key, ...options.command];
|
|
30
|
+
const execution = await execute(exec, command);
|
|
31
|
+
if (execution.exitCode !== 0) {
|
|
32
|
+
throw CommandError.from(command, execution);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export async function unbindKey(exec, options) {
|
|
36
|
+
assertNotEmpty("table", options.table);
|
|
37
|
+
assertNotEmpty("key", options.key);
|
|
38
|
+
const command = ["tmux", "unbind-key", "-T", options.table, options.key];
|
|
39
|
+
const execution = await execute(exec, command);
|
|
40
|
+
if (execution.exitCode !== 0) {
|
|
41
|
+
throw CommandError.from(command, execution);
|
|
42
|
+
}
|
|
43
|
+
}
|
package/dist/session.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface NewSessionOptions {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function hasSession(exec: Exec, session: string): Promise<boolean>;
|
|
11
11
|
export declare function setEnvironment(exec: Exec, session: string, key: string, value: string): Promise<void>;
|
|
12
|
+
/** Sets a session option; a name starting with `@` is a user option formats can read. */
|
|
13
|
+
export declare function setSessionOption(exec: Exec, session: string, name: string, value: string): Promise<void>;
|
|
12
14
|
export declare function setSessionTitle(exec: Exec, session: string): Promise<void>;
|
|
13
15
|
export declare function killSession(exec: Exec, session: string): Promise<void>;
|
|
14
16
|
export declare function newSession(exec: Exec, options: NewSessionOptions): Promise<WindowPaneIds>;
|
package/dist/session.js
CHANGED
|
@@ -21,6 +21,16 @@ export async function setEnvironment(exec, session, key, value) {
|
|
|
21
21
|
throw CommandError.from(command, execution);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
/** Sets a session option; a name starting with `@` is a user option formats can read. */
|
|
25
|
+
export async function setSessionOption(exec, session, name, value) {
|
|
26
|
+
assertNotEmpty("session", session);
|
|
27
|
+
assertNotEmpty("name", name);
|
|
28
|
+
const command = ["tmux", "set-option", "-t", `=${session}:`, name, value];
|
|
29
|
+
const execution = await execute(exec, command);
|
|
30
|
+
if (execution.exitCode !== 0) {
|
|
31
|
+
throw CommandError.from(command, execution);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
24
34
|
export async function setSessionTitle(exec, session) {
|
|
25
35
|
assertNotEmpty("session", session);
|
|
26
36
|
const setTitlesCommand = ["tmux", "set-option", "-t", session, "set-titles", "on"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@termwire/tmux",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "A thin, typed adapter for tmux 3.2 or newer.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tmux",
|
|
7
|
+
"adapter",
|
|
8
|
+
"terminal",
|
|
9
|
+
"session",
|
|
10
|
+
"pane",
|
|
11
|
+
"typescript",
|
|
12
|
+
"cli"
|
|
13
|
+
],
|
|
4
14
|
"type": "module",
|
|
5
15
|
"main": "./dist/index.js",
|
|
6
16
|
"types": "./dist/index.d.ts",
|