tmux-tui 1.1.0 → 1.1.1
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 +37 -61
- package/dist/tmuxtui.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# tmuxtui
|
|
2
2
|
|
|
3
|
+
[中文文档](README_zh.md)
|
|
4
|
+
|
|
3
5
|
Interactive terminal UI for managing tmux sessions. Browse, create, rename, detach, and kill sessions without memorizing tmux commands.
|
|
4
6
|
|
|
5
7
|
## Features
|
|
6
8
|
|
|
7
|
-
- **Session browser** — list all tmux sessions sorted by last used, with window count and creation time
|
|
8
|
-
- **Quick attach** — select and attach to any session instantly
|
|
9
|
+
- **Session browser** — list all tmux sessions sorted by last used, with window count, working directory, and creation time
|
|
10
|
+
- **Quick attach** — select and attach to any session instantly; auto sets terminal tab title to `[tmux] session_name`
|
|
9
11
|
- **Create sessions** — new session with custom name and working directory
|
|
12
|
+
- **Window manager** — press `c` to enter config mode: create, rename, delete windows, and initialize pane layouts
|
|
13
|
+
- **Pane layout presets** — 9 built-in layouts (IDE, Quad, Triple, etc.) with live preview
|
|
10
14
|
- **Rename / Detach / Kill** — full session lifecycle management
|
|
11
15
|
- **Works everywhere** — runs inside or outside tmux (auto-detects and uses `switch-client` or `attach-session`)
|
|
12
16
|
- **`init` command** — register the current directory as a new tmux session in one step
|
|
@@ -40,77 +44,49 @@ Keyboard shortcuts:
|
|
|
40
44
|
| `r` | Rename session |
|
|
41
45
|
| `x` | Detach session |
|
|
42
46
|
| `d` | Kill session (with confirm) |
|
|
47
|
+
| `c` | Config — window management |
|
|
43
48
|
| `q` | Quit |
|
|
44
49
|
|
|
45
50
|
When creating a new session, press `Tab` to switch between the name and path fields.
|
|
46
51
|
|
|
47
|
-
###
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
tmuxtui init
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Creates a new tmux session named after the current directory and opens it with tmuxtui.
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
[English](#tmuxtui) | [中文](#tmuxtui-1)
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
# tmuxtui
|
|
62
|
-
|
|
63
|
-
tmux 会话管理的交互式终端界面。无需记忆 tmux 命令,即可浏览、创建、重命名、分离和销毁会话。
|
|
64
|
-
|
|
65
|
-
## 功能
|
|
66
|
-
|
|
67
|
-
- **会话浏览** — 按最近使用排序列出所有 tmux 会话,显示窗口数和创建时间
|
|
68
|
-
- **快速接入** — 选中会话后一键 attach
|
|
69
|
-
- **创建会话** — 自定义名称和工作目录
|
|
70
|
-
- **重命名 / 分离 / 销毁** — 完整的会话生命周期管理
|
|
71
|
-
- **全场景适配** — 在 tmux 内外均可运行(自动检测并使用 `switch-client` 或 `attach-session`)
|
|
72
|
-
- **`init` 命令** — 一行命令将当前目录注册为新的 tmux 会话
|
|
73
|
-
|
|
74
|
-
## 环境要求
|
|
75
|
-
|
|
76
|
-
- Node.js >= 18
|
|
77
|
-
- tmux >= 3.2
|
|
78
|
-
|
|
79
|
-
## 安装
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
npm install -g tmux-tui
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## 使用
|
|
86
|
-
|
|
87
|
-
### 交互式 TUI
|
|
52
|
+
### Config mode (window management)
|
|
88
53
|
|
|
89
|
-
|
|
90
|
-
tmuxtui
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
快捷键:
|
|
94
|
-
|
|
95
|
-
| 按键 | 操作 |
|
|
96
|
-
|------|------|
|
|
97
|
-
| `↑` `↓` | 选择会话 |
|
|
98
|
-
| `Enter` | 接入会话 |
|
|
99
|
-
| `n` | 新建会话 |
|
|
100
|
-
| `r` | 重命名会话 |
|
|
101
|
-
| `x` | 分离会话 |
|
|
102
|
-
| `d` | 销毁会话(需确认) |
|
|
103
|
-
| `q` | 退出 |
|
|
54
|
+
Press `c` on any session to enter config mode. This lets you manage windows within the selected session.
|
|
104
55
|
|
|
105
|
-
|
|
56
|
+
| Key | Action |
|
|
57
|
+
|-----|--------|
|
|
58
|
+
| `↑` `↓` | Select window |
|
|
59
|
+
| `n` | New window |
|
|
60
|
+
| `r` | Rename window |
|
|
61
|
+
| `d` | Delete window (with confirm) |
|
|
62
|
+
| `i` | Init pane layout (only for single-pane inactive windows) |
|
|
63
|
+
| `Esc` | Back to session list |
|
|
64
|
+
|
|
65
|
+
#### Pane layout presets
|
|
66
|
+
|
|
67
|
+
When you press `i`, you can choose from 9 built-in pane layouts:
|
|
68
|
+
|
|
69
|
+
| Layout | Panes | Description |
|
|
70
|
+
|--------|-------|-------------|
|
|
71
|
+
| 1. Single | 1 | No splits |
|
|
72
|
+
| 2. H-Split | 2 | Horizontal 50/50 |
|
|
73
|
+
| 3. V-Split | 2 | Vertical 50/50 |
|
|
74
|
+
| 4. IDE | 2 | Left sidebar (25%) + main |
|
|
75
|
+
| 5. IDE+Term | 3 | IDE + bottom terminal |
|
|
76
|
+
| 6. Triple | 3 | Three equal columns |
|
|
77
|
+
| 7. IDE+Side | 3 | IDE with right sidebar |
|
|
78
|
+
| 8. Quad | 4 | 2x2 grid |
|
|
79
|
+
| 9. IDE Pro | 4 | IDE + split right panel |
|
|
106
80
|
|
|
107
|
-
###
|
|
81
|
+
### Quick register current project
|
|
108
82
|
|
|
109
83
|
```bash
|
|
110
84
|
tmuxtui init
|
|
85
|
+
# or
|
|
86
|
+
tmuxtui -i
|
|
111
87
|
```
|
|
112
88
|
|
|
113
|
-
|
|
89
|
+
Creates a new tmux session named after the current directory and opens it with tmuxtui.
|
|
114
90
|
|
|
115
91
|
## License
|
|
116
92
|
|
package/dist/tmuxtui.js
CHANGED
|
@@ -287,7 +287,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
|
|
|
287
287
|
`))}patchConsole(){this.options.debug||(this.restoreConsole=By((l,c)=>{l==="stdout"&&this.writeToStdout(c),l==="stderr"&&(c.startsWith("The above error occurred")||this.writeToStderr(c))}))}initKittyKeyboard(){if(!this.options.kittyKeyboard)return;let l=this.options.kittyKeyboard,c=l.mode??"auto";if(c==="disabled"||!this.options.stdin.isTTY||!this.options.stdout.isTTY)return;let f=l.flags??["disambiguateEscapeCodes"];if(c==="enabled"){this.enableKittyProtocol(f);return}let E=Wg.env.TERM??"",p=Wg.env.TERM_PROGRAM??"",m="KITTY_WINDOW_ID"in Wg.env||E==="xterm-kitty"||p==="WezTerm"||p==="ghostty";!Fi&&m&&this.confirmKittySupport(f)}confirmKittySupport(l){let{stdin:c,stdout:f}=this.options,E=[],p=()=>{this.cancelKittyDetection=void 0,clearTimeout(D),c.removeListener("data",m);let v=lF(E);E=[],v.length>0&&c.unshift(Buffer.from(v))},m=v=>{let x=typeof v=="string"?Buffer.from(v):v;for(let H of x)E.push(H);uF(E)&&(p(),this.isUnmounted||this.enableKittyProtocol(l))};c.on("data",m);let D=setTimeout(p,200);this.cancelKittyDetection=p,f.write("\x1B[?u")}enableKittyProtocol(l){this.options.stdout.write(`\x1B[>${e2(l)}u`),this.kittyProtocolEnabled=!0}};var oF=(n,l)=>{let c={stdout:_I.stdout,stdin:_I.stdin,stderr:_I.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,maxFps:30,incrementalRendering:!1,concurrent:!1,...cF(l)},f=sF(c.stdout,()=>new NB(c),c.concurrent??!1);return f.render(n),{rerender:f.render,unmount(){f.unmount()},waitUntilExit:f.waitUntilExit,cleanup:()=>kg.delete(c.stdout),clear:f.clear}},qQ=oF,cF=(n={})=>n instanceof iF?{stdout:n,stdin:_I.stdin}:n,sF=(n,l,c)=>{let f=kg.get(n);return f?f.isConcurrent!==c&&console.warn(`Warning: render() was called with concurrent: ${c}, but the existing instance for this stdout uses concurrent: ${f.isConcurrent}. The concurrent option only takes effect on the first render. Call unmount() first if you need to change the rendering mode.`):(f=l(),kg.set(n,f)),f};var rF=Zt(Fp(),1);var UI=Zt(Ve(),1);var a2=Zt(Ve(),1);var fF=Zt(Ve(),1);var gF=Zt(Ve(),1);var XQ=Zt(Ve(),1);import{Buffer as EF}from"node:buffer";var CF=/^(?:\x1b)([a-zA-Z0-9])$/,BF=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,l2={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},i2=[...Object.values(l2),"backspace"],dF=n=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(n),pF=n=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(n),o2=/^\x1b\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,IF=/^\x1b\[(\d+);(\d+):(\d+)([A-Za-z~])$/,mF={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},QF={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},u2={27:"escape",9:"tab",127:"delete",8:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},c2=n=>n>=0&&n<=1114111&&!(n>=55296&&n<=57343),jQ=n=>c2(n)?String.fromCodePoint(n):"?";function s2(n){return n===3?"release":n===2?"repeat":"press"}function r2(n){return{ctrl:!!(n&Hi.ctrl),shift:!!(n&Hi.shift),meta:!!(n&Hi.meta),option:!!(n&Hi.alt),super:!!(n&Hi.super),hyper:!!(n&Hi.hyper),capsLock:!!(n&Hi.capsLock),numLock:!!(n&Hi.numLock)}}var hF=n=>{let l=o2.exec(n);if(!l)return null;let c=parseInt(l[1],10),f=l[2]?Math.max(0,parseInt(l[2],10)-1):0,E=l[3]?parseInt(l[3],10):1,p=l[4];if(!c2(c))return null;let m;p&&(m=p.split(":").map(x=>jQ(parseInt(x,10))).join(""));let D,v;return c===32?(D="space",v=!0):c===13?(D="return",v=!0):u2[c]?(D=u2[c],v=!1):c>=1&&c<=26?(D=String.fromCodePoint(c+96),v=!1):(D=jQ(c).toLowerCase(),v=!0),v&&!m&&(m=jQ(c)),{name:D,...r2(f),eventType:s2(E),sequence:n,raw:n,isKittyProtocol:!0,isPrintable:v,text:m}},DF=n=>{let l=IF.exec(n);if(!l)return null;let c=parseInt(l[1],10),f=Math.max(0,parseInt(l[2],10)-1),E=parseInt(l[3],10),p=l[4],m=p==="~"?QF[c]:mF[p];return m?{name:m,...r2(f),eventType:s2(E),sequence:n,raw:n,isKittyProtocol:!0,isPrintable:!1}:null},yF=(n="")=>{let l;EF.isBuffer(n)?n[0]>127&&n[1]===void 0?(n[0]-=128,n="\x1B"+String(n)):n=String(n):n!==void 0&&typeof n!="string"?n=String(n):n||(n="");let c=hF(n);if(c)return c;let f=DF(n);if(f)return f;if(o2.test(n))return{name:"",ctrl:!1,meta:!1,shift:!1,option:!1,sequence:n,raw:n,isKittyProtocol:!0,isPrintable:!1};let E={name:"",ctrl:!1,meta:!1,shift:!1,option:!1,sequence:n,raw:n};if(E.sequence=E.sequence||n||E.name,n==="\r"||n==="\x1B\r")E.raw=void 0,E.name="return",E.option=n.length===2;else if(n===`
|
|
288
288
|
`)E.name="enter";else if(n===" ")E.name="tab";else if(n==="\b"||n==="\x1B\b")E.name="backspace",E.meta=n.charAt(0)==="\x1B";else if(n==="\x7F"||n==="\x1B\x7F")E.name="delete",E.meta=n.charAt(0)==="\x1B";else if(n==="\x1B"||n==="\x1B\x1B")E.name="escape",E.meta=n.length===2;else if(n===" "||n==="\x1B ")E.name="space",E.meta=n.length===2;else if(n.length===1&&n<="")E.name=String.fromCharCode(n.charCodeAt(0)+97-1),E.ctrl=!0;else if(n.length===1&&n>="0"&&n<="9")E.name="number";else if(n.length===1&&n>="a"&&n<="z")E.name=n;else if(n.length===1&&n>="A"&&n<="Z")E.name=n.toLowerCase(),E.shift=!0;else if(l=CF.exec(n))E.meta=!0,E.shift=/^[A-Z]$/.test(l[1]);else if(l=BF.exec(n)){let p=[...n];p[0]==="\x1B"&&p[1]==="\x1B"&&(E.option=!0);let m=[l[1],l[2],l[4],l[6]].filter(Boolean).join(""),D=(l[3]||l[5]||1)-1;E.ctrl=!!(D&4),E.meta=!!(D&10),E.shift=!!(D&1),E.code=m,E.name=l2[m],E.shift=dF(m)||E.shift,E.ctrl=pF(m)||E.ctrl}return E},f2=yF;var g2=Zt(Ve(),1);var SF=()=>(0,g2.useContext)(SI),MI=SF;var vF=(n,l={})=>{let{stdin:c,setRawMode:f,internal_exitOnCtrlC:E,internal_eventEmitter:p}=MI();(0,XQ.useEffect)(()=>{if(l.isActive!==!1)return f(!0),()=>{f(!1)}},[l.isActive,f]),(0,XQ.useEffect)(()=>{if(l.isActive===!1)return;let m=D=>{let v=f2(D),x={upArrow:v.name==="up",downArrow:v.name==="down",leftArrow:v.name==="left",rightArrow:v.name==="right",pageDown:v.name==="pagedown",pageUp:v.name==="pageup",home:v.name==="home",end:v.name==="end",return:v.name==="return",escape:v.name==="escape",ctrl:v.ctrl,shift:v.shift,tab:v.name==="tab",backspace:v.name==="backspace",delete:v.name==="delete",meta:v.meta||v.name==="escape"||v.option,super:v.super??!1,hyper:v.hyper??!1,capsLock:v.capsLock??!1,numLock:v.numLock??!1,eventType:v.eventType},H;v.isKittyProtocol?v.isPrintable?H=v.text??v.name:v.ctrl&&v.name.length===1?H=v.name:H="":v.ctrl?H=v.name:H=v.sequence,!v.isKittyProtocol&&i2.includes(v.name)&&(H=""),H.startsWith("\x1B")&&(H=H.slice(1)),H.length===1&&typeof H[0]=="string"&&/[A-Z]/.test(H[0])&&(x.shift=!0),(!(H==="c"&&x.ctrl)||!E)&&El.batchedUpdates(()=>{n(H,x)})};return p?.on("input",m),()=>{p?.removeListener("input",m)}},[l.isActive,c,E,n])},VQ=vF;var E2=Zt(Ve(),1);var RF=()=>(0,E2.useContext)(yI),ZQ=RF;var NF=Zt(Ve(),1);var xF=Zt(Ve(),1);var kQ=Zt(Ve(),1);var TF=Zt(Ve(),1);var FF=Zt(Ve(),1);var bI=Zt(Ve(),1);import{execSync as bF}from"child_process";import{basename as HF}from"path";var _u=Zt(Ve(),1);import{execSync as ti}from"child_process";function WQ(){let n="#{session_name} #{session_windows} #{session_created} #{session_attached} #{session_id} #{session_path} #{session_last_attached}";try{let l=ti(`tmux list-sessions -F '${n}'`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim();return l?l.split(`
|
|
289
289
|
`).map(f=>{let[E,p,m,D,v,x,H]=f.split(" ");return{name:E,windows:parseInt(p,10),created:parseInt(m,10),attached:D==="1",sessionId:v,path:x||"",lastAttached:parseInt(H,10)}}).sort((f,E)=>E.lastAttached-f.lastAttached):[]}catch{return[]}}function PQ(n,l){let c=n.replace(/'/g,"'\\''"),f=l.replace(/'/g,"'\\''"),E=l?`tmux new-session -d -s '${c}' -c '${f}'`:`tmux new-session -d -s '${c}'`;ti(E,{stdio:"pipe"})}function C2(n){let l=n.replace(/'/g,"'\\''");ti(`tmux kill-session -t '${l}'`,{stdio:"pipe"})}function B2(n,l){let c=n.replace(/'/g,"'\\''"),f=l.replace(/'/g,"'\\''");ti(`tmux rename-session -t '${c}' '${f}'`,{stdio:"pipe"})}function d2(n){let l=n.replace(/'/g,"'\\''");ti(`tmux detach-client -s '${l}'`,{stdio:"pipe"})}function $Q(n){let l="#{window_name} #{window_index} #{window_panes} #{window_active}",c=n.replace(/'/g,"'\\''");try{let f=ti(`tmux list-windows -t '${c}' -F '${l}'`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim();return f?f.split(`
|
|
290
|
-
`).map(E=>{let[p,m,D,v]=E.split(" ");return{name:p,index:parseInt(m,10),panes:parseInt(D,10),active:v==="1"}}):[]}catch{return[]}}function p2(n,l,c){let f=n.replace(/'/g,"'\\''"),E=l.replace(/'/g,"'\\''"),p=c?c.replace(/'/g,"'\\''"):"",m=p?`tmux new-window -d -t '${f}' -n '${E}' -c '${p}'`:`tmux new-window -d -t '${f}' -n '${E}'`;ti(m,{stdio:"pipe"})}function I2(n,l,c){let f=n.replace(/'/g,"'\\''"),E=c.replace(/'/g,"'\\''");ti(`tmux rename-window -t '${f}':${l} '${E}'`,{stdio:"pipe"})}function m2(n,l){let c=n.replace(/'/g,"'\\''");ti(`tmux kill-window -t '${c}':${l}`,{stdio:"pipe"})}var Hc=[{id:1,name:"Single",panes:1,preview:["\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502 1 \u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"],splits:[]},{id:2,name:"H-Split",panes:2,preview:["\u250C\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2510","\u2502 1 \u2502 2 \u2502","\u2514\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:50}]},{id:3,name:"V-Split",panes:2,preview:["\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502 1 \u2502","\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","\u2502 2 \u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!1,percentage:50}]},{id:4,name:"IDE",panes:2,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2510","\u25021 \u2502 2 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:75}]},{id:5,name:"IDE+Term",panes:3,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2510","\u2502 \u2502 2 \u2502","\u25021 \u251C\u2500\u2500\u2500\u2500\u2524","\u2502 \u2502 3 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:75},{pane:1,horizontal:!1,percentage:50}]},{id:6,name:"Triple",panes:3,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u252C\u2500\u2500\u2510","\u25021 \u25022 \u25023 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2534\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:66},{pane:1,horizontal:!0,percentage:50}]},{id:7,name:"IDE+Side",panes:3,preview:["\u250C\u2500\u252C\u2500\u2500\u252C\u2500\u2510","\u25021\u25022 \u25023\u2502","\u2514\u2500\u2534\u2500\u2500\u2534\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:80},{pane:1,horizontal:!0,percentage:25}]},{id:8,name:"Quad",panes:4,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2510","\u25021 \u25022 \u2502","\u251C\u2500\u2500\u253C\u2500\u2500\u2524","\u25023 \u25024 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:50},{pane:0,horizontal:!1,percentage:50},{pane:1,horizontal:!1,percentage:50}]},{id:9,name:"IDE Pro",panes:4,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2510","\u2502 \u2502 2 \u2502","\u25021 \u251C\u2500\u2500\u252C\u2500\u2500\u2524","\u2502 \u2502 3\u25024 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2534\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:75},{pane:1,horizontal:!1,percentage:40},{pane:2,horizontal:!0,percentage:50}]}];function Q2(n,l,c){let f=Hc.find(D=>D.id===c);if(!f||f.splits.length===0)return;let p=`'${n.replace(/'/g,"'\\''")}':${l}`,m=0;try{let D=ti("tmux show-option -g pane-base-index",{encoding:"utf-8"}).trim();m=parseInt(D.split(" ").pop()||"0",10)}catch{}for(let D of f.splits){let v=D.horizontal?"-h":"-v",x=`${p}.${m+D.pane}`;ti(`tmux split-window -t ${x} ${v} -p ${D.percentage}`,{stdio:"pipe"})}}function h2(n){let l=new Date(n*1e3),c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],f=l.getHours().toString().padStart(2,"0"),E=l.getMinutes().toString().padStart(2,"0");return`${c[l.getMonth()]} ${l.getDate()} ${f}:${E}`}var $=Zt(eh(),1);function MF({interactive:n,onSelect:l,onCreate:c,onKill:f,onRename:E,onDetach:p}){let{exit:m}=ZQ(),[D,v]=(0,_u.useState)(WQ),[x,H]=(0,_u.useState)(0),[K,N]=(0,_u.useState)("list"),[L,X]=(0,_u.useState)(""),[q,J]=(0,_u.useState)(""),[Qt,ee]=(0,_u.useState)("name"),[Ht,It]=(0,_u.useState)(""),[Xt,He]=(0,_u.useState)(null),[Tt,Mt]=(0,_u.useState)([]),[dt,Ot]=(0,_u.useState)(0),[ue,yt]=(0,_u.useState)("list"),[$e,we]=(0,_u.useState)(0),gt=()=>{let st=WQ();v(st),H(nt=>Math.min(nt,Math.max(0,st.length-1)))},xt=()=>{if(!Xt)return;let st=$Q(Xt.name);Mt(st),Ot(nt=>Math.min(nt,Math.max(0,st.length-1)))};if(n&&VQ((st,nt)=>{if(K==="new"){if(nt.escape){N("list"),X(""),J(""),It("");return}if(nt.tab){ee(ht=>ht==="name"?"path":"name");return}if(nt.return){if(!L.trim()){It("Session name is required");return}let ht=(q||process.cwd()).replace(/^~/,process.env.HOME||"~");c?.(L.trim(),ht),m();return}if(nt.backspace||nt.delete){Qt==="name"?X(ht=>ht.slice(0,-1)):J(ht=>ht.slice(0,-1)),It("");return}st&&!nt.ctrl&&!nt.meta&&(Qt==="name"?X(ht=>ht+st):J(ht=>ht+st),It(""));return}if(K==="rename"){if(nt.escape){N("list"),X(""),It("");return}if(nt.return){if(!L.trim()){It("Name cannot be empty");return}E?.(D[x].name,L.trim()),gt(),N("list"),X(""),It("");return}if(nt.backspace||nt.delete){X(ht=>ht.slice(0,-1)),It("");return}st&&!nt.ctrl&&!nt.meta&&(X(ht=>ht+st),It(""));return}if(K==="confirm-kill"){if(nt.escape||st==="n"){N("list");return}(st==="y"||nt.return)&&(f?.(D[x].name),gt(),N("list"));return}if(K==="config"){if(ue==="new"){if(nt.escape){yt("list"),X(""),It("");return}if(nt.return){if(!L.trim()){It("Window name is required");return}try{p2(Xt.name,L.trim(),Xt.path)}catch(Ae){It(Ae.message);return}xt(),yt("list"),X(""),It("");return}if(nt.backspace||nt.delete){X(Ae=>Ae.slice(0,-1)),It("");return}st&&!nt.ctrl&&!nt.meta&&(X(Ae=>Ae+st),It(""));return}if(ue==="rename"){if(nt.escape){yt("list"),X(""),It("");return}if(nt.return){if(!L.trim()){It("Name cannot be empty");return}try{I2(Xt.name,Tt[dt].index,L.trim())}catch(Ae){It(Ae.message);return}xt(),yt("list"),X(""),It("");return}if(nt.backspace||nt.delete){X(Ae=>Ae.slice(0,-1)),It("");return}st&&!nt.ctrl&&!nt.meta&&(X(Ae=>Ae+st),It(""));return}if(ue==="confirm-delete"){if(nt.escape||st==="n"){yt("list");return}if(st==="y"||nt.return){try{m2(Xt.name,Tt[dt].index)}catch(Ae){It(Ae.message),yt("list");return}xt(),yt("list")}return}if(ue==="init-panes"){if(nt.escape){yt("list"),It("");return}if(nt.return){try{Q2(Xt.name,Tt[dt].index,Hc[$e].id)}catch(Ae){It(Ae.message);return}xt(),yt("list");return}nt.upArrow?we(Ae=>(Ae-1+Hc.length)%Hc.length):nt.downArrow&&we(Ae=>(Ae+1)%Hc.length);return}if(nt.escape){gt(),N("list"),He(null);return}if(st==="n"){yt("new"),X(""),It("");return}if(st==="r"&&Tt.length>0){yt("rename"),X(Tt[dt].name),It("");return}if(st==="d"&&Tt.length>0){yt("confirm-delete");return}let ht=Tt.length>0&&Tt[dt].panes===1&&!Tt[dt].active;if(st==="i"&&ht){we(0),yt("init-panes"),It("");return}nt.upArrow?Ot(Ae=>(Ae-1+Tt.length)%Tt.length):nt.downArrow&&Ot(Ae=>(Ae+1)%Tt.length);return}if(st==="q"){m();return}if(st==="n"){N("new"),ee("name"),X(""),J(""),It("");return}if(st==="r"&&D.length>0){N("rename"),X(D[x].name),It("");return}if(st==="x"&&D.length>0){p?.(D[x].name),gt();return}if(st==="d"&&D.length>0){N("confirm-kill");return}if(st==="c"&&D.length>0){let ht=D[x];He(ht),Mt($Q(ht.name)),Ot(0),yt("list"),It(""),N("config");return}nt.upArrow?H(ht=>(ht-1+D.length)%D.length):nt.downArrow?H(ht=>(ht+1)%D.length):nt.return&&D.length>0&&(l?.(D[x]),m())}),K==="new")return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,$.jsxs)(ct,{children:[" ","new session"]})]}),(0,$.jsxs)(Lt,{marginBottom:1,flexDirection:"column",children:[(0,$.jsxs)(Lt,{children:[(0,$.jsx)(ct,{color:Qt==="name"?"cyan":"white",bold:Qt==="name",children:"Name: "}),(0,$.jsx)(ct,{color:Qt==="name"?"cyan":"white",children:L}),Qt==="name"&&(0,$.jsx)(ct,{backgroundColor:"cyan",children:" "})]}),(0,$.jsxs)(Lt,{children:[(0,$.jsx)(ct,{color:Qt==="path"?"cyan":"white",bold:Qt==="path",children:"Path: "}),(0,$.jsx)(ct,{color:Qt==="path"?"cyan":"white",children:q}),Qt==="path"&&(0,$.jsx)(ct,{backgroundColor:"cyan",children:" "})]})]}),Ht&&(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{color:"red",children:Ht})}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"tab switch | \u21B5 create | esc cancel"})})]});if(K==="rename")return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,$.jsxs)(ct,{children:[" ","rename session"]})]}),(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{children:"New name: "}),(0,$.jsx)(ct,{color:"cyan",children:L}),(0,$.jsx)(ct,{backgroundColor:"cyan",children:" "})]}),Ht&&(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{color:"red",children:Ht})}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"\u21B5 confirm | esc cancel"})})]});if(K==="confirm-kill"&&D.length>0){let st=D[x];return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"red",children:" \u26A0 delete "})}),(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{children:"Kill session "}),(0,$.jsx)(ct,{bold:!0,color:"red",children:st.name}),(0,$.jsx)(ct,{children:"?"})]}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"y confirm | n/esc cancel"})})]})}if(K==="config"&&Xt){if(ue==="new")return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,$.jsxs)(ct,{children:[" ","new window"]})]}),(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{children:"Name: "}),(0,$.jsx)(ct,{color:"cyan",children:L}),(0,$.jsx)(ct,{backgroundColor:"cyan",children:" "})]}),Ht&&(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{color:"red",children:Ht})}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"\u21B5 create | esc cancel"})})]});if(ue==="rename")return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,$.jsxs)(ct,{children:[" ","rename window"]})]}),(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{children:"New name: "}),(0,$.jsx)(ct,{color:"cyan",children:L}),(0,$.jsx)(ct,{backgroundColor:"cyan",children:" "})]}),Ht&&(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{color:"red",children:Ht})}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"\u21B5 confirm | esc cancel"})})]});if(ue==="confirm-delete"&&Tt.length>0){let nt=Tt[dt];return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"red",children:" \u26A0 delete "})}),(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{children:"Delete window "}),(0,$.jsx)(ct,{bold:!0,color:"red",children:nt.name}),(0,$.jsx)(ct,{children:"?"})]}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"y confirm | n/esc cancel"})})]})}if(ue==="list")return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,$.jsxs)(ct,{children:[" ",Xt.name]}),(0,$.jsxs)(ct,{dimColor:!0,children:[" windows (",Tt.length,")"]})]}),Tt.length===0?(0,$.jsx)(ct,{dimColor:!0,children:"No windows found"}):Tt.map((nt,ht)=>(0,$.jsxs)(Lt,{children:[(0,$.jsx)(ct,{children:ht===dt?"\u25B8 ":" "}),(0,$.jsx)(ct,{bold:!0,color:ht===dt?"cyan":nt.active?"green":"white",children:nt.name.padEnd(20)}),(0,$.jsxs)(ct,{dimColor:!0,children:[nt.panes," pane",nt.panes!==1?"s":""]}),(0,$.jsx)(ct,{color:"yellow",children:nt.active?" active":""})]},nt.index)),n&&(0,$.jsxs)(Lt,{marginTop:1,children:[(0,$.jsx)(ct,{dimColor:!0,children:"\u2191\u2193 select | "}),(0,$.jsx)(ct,{color:"green",bold:!0,children:"n"}),(0,$.jsx)(ct,{dimColor:!0,children:" new | "}),(0,$.jsx)(ct,{color:"yellow",bold:!0,children:"r"}),(0,$.jsx)(ct,{dimColor:!0,children:" rename | "}),(0,$.jsx)(ct,{color:"red",bold:!0,children:"d"}),(0,$.jsx)(ct,{dimColor:!0,children:" delete | "}),Tt.length>0&&Tt[dt].panes===1&&!Tt[dt].active&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ct,{color:"cyan",bold:!0,children:"i"}),(0,$.jsx)(ct,{dimColor:!0,children:" init panes | "})]}),(0,$.jsx)(ct,{dimColor:!0,children:"esc back"})]})]});let st=Hc[$e];return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,$.jsxs)(ct,{children:[" ",Tt[dt]?.name]}),(0,$.jsx)(ct,{dimColor:!0,children:" init panes"})]}),Hc.map((nt,ht)=>(0,$.jsxs)(Lt,{children:[(0,$.jsx)(ct,{children:ht===$e?"\u25B8 ":" "}),(0,$.jsx)(ct,{bold:!0,color:ht===$e?"cyan":"white",children:`${nt.id}. ${nt.name.padEnd(12)}`}),(0,$.jsx)(ct,{dimColor:!0,children:`${nt.panes} pane${nt.panes!==1?"s":""}`})]},nt.id)),(0,$.jsxs)(Lt,{marginTop:1,flexDirection:"column",children:[(0,$.jsx)(ct,{dimColor:!0,children:"Preview:"}),st.preview.map((nt,ht)=>(0,$.jsx)(ct,{color:"cyan",children:nt},ht))]}),Ht&&(0,$.jsx)(Lt,{marginTop:1,children:(0,$.jsx)(ct,{color:"red",children:Ht})}),n&&(0,$.jsx)(Lt,{marginTop:1,children:(0,$.jsx)(ct,{dimColor:!0,children:"\u2191\u2193 select | \u21B5 apply | esc cancel"})})]})}return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,$.jsxs)(ct,{dimColor:!0,children:[" ","tmux sessions (",D.length,")"]})]}),D.length===0?(0,$.jsx)(ct,{dimColor:!0,children:"No tmux sessions found"}):D.map((st,nt)=>(0,$.jsxs)(Lt,{flexDirection:"column",marginBottom:1,children:[(0,$.jsxs)(Lt,{children:[(0,$.jsx)(ct,{children:nt===x?"\u25B8 ":" "}),(0,$.jsx)(ct,{bold:!0,color:nt===x?"cyan":st.attached?"green":"white",children:st.name.padEnd(18)}),(0,$.jsxs)(ct,{dimColor:!0,children:[st.windows," win",st.windows!==1?"s":""]}),(0,$.jsx)(ct,{color:"yellow",children:st.attached?" attached ":" "}),(0,$.jsx)(ct,{dimColor:!0,children:h2(st.created)})]}),st.path&&(0,$.jsxs)(ct,{dimColor:!0,children:[" ",st.path.replace(process.env.HOME||"","~")]})]},st.sessionId)),n&&(0,$.jsxs)(Lt,{marginTop:1,children:[(0,$.jsx)(ct,{dimColor:!0,children:"\u2191\u2193 select | \u21B5 attach | "}),(0,$.jsx)(ct,{color:"green",bold:!0,children:"n"}),(0,$.jsx)(ct,{dimColor:!0,children:" new | "}),(0,$.jsx)(ct,{color:"yellow",bold:!0,children:"r"}),(0,$.jsx)(ct,{dimColor:!0,children:" rename | "}),(0,$.jsx)(ct,{color:"blue",bold:!0,children:"x"}),(0,$.jsx)(ct,{dimColor:!0,children:" detach | "}),(0,$.jsx)(ct,{color:"red",bold:!0,children:"d"}),(0,$.jsx)(ct,{dimColor:!0,children:" delete | "}),(0,$.jsx)(ct,{color:"magenta",bold:!0,children:"c"}),(0,$.jsx)(ct,{dimColor:!0,children:" config | "}),(0,$.jsx)(ct,{dimColor:!0,children:"q quit"})]})]})}function Ah({onSelect:n,onCreate:l,onKill:c,onRename:f,onDetach:E}){return(0,$.jsx)(MF,{interactive:!!process.stdin.isTTY,onSelect:n,onCreate:l,onKill:c,onRename:f,onDetach:E})}function v2(n){process.stdout.write(`\x1B]0;[tmux] ${n}\x07`);let l=process.env.TMUX?`tmux switch-client -t ${n}`:`tmux attach-session -t ${n}`;bF(l,{stdio:"inherit"})}var R2=process.argv.slice(2);if(R2[0]==="init"||R2[0]==="-i"){let n=HF(process.cwd()),l=process.cwd();try{PQ(n,l),console.log(`${n} \u9879\u76EE\u5DF2\u7ECF\u6DFB\u52A0\u5230 tmuxtui \u4E2D`)}catch{console.error("\u521B\u5EFA session \u5931\u8D25\uFF0C\u53EF\u80FD\u5DF2\u5B58\u5728\u540C\u540D session"),process.exit(1)}process.exit(0)}var Pg={session:null,newSession:null},GF=qQ(N2.default.createElement(Ah,{onSelect:n=>{Pg.session=n},onCreate:(n,l)=>{PQ(n,l),Pg.newSession=n},onKill:n=>{C2(n)},onRename:(n,l)=>{B2(n,l)},onDetach:n=>{d2(n)}}));await GF.waitUntilExit();try{Pg.session?v2(Pg.session.name):Pg.newSession&&v2(Pg.newSession)}catch{process.exit(1)}
|
|
290
|
+
`).map(E=>{let[p,m,D,v]=E.split(" ");return{name:p,index:parseInt(m,10),panes:parseInt(D,10),active:v==="1"}}):[]}catch{return[]}}function p2(n,l,c){let f=n.replace(/'/g,"'\\''"),E=l.replace(/'/g,"'\\''"),p=c?c.replace(/'/g,"'\\''"):"",m=p?`tmux new-window -d -t '${f}' -n '${E}' -c '${p}'`:`tmux new-window -d -t '${f}' -n '${E}'`;ti(m,{stdio:"pipe"})}function I2(n,l,c){let f=n.replace(/'/g,"'\\''"),E=c.replace(/'/g,"'\\''");ti(`tmux rename-window -t '${f}':${l} '${E}'`,{stdio:"pipe"})}function m2(n,l){let c=n.replace(/'/g,"'\\''");ti(`tmux kill-window -t '${c}':${l}`,{stdio:"pipe"})}var Hc=[{id:1,name:"Single",panes:1,preview:["\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502 1 \u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"],splits:[]},{id:2,name:"H-Split",panes:2,preview:["\u250C\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2510","\u2502 1 \u2502 2 \u2502","\u2514\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:50}]},{id:3,name:"V-Split",panes:2,preview:["\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502 1 \u2502","\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","\u2502 2 \u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!1,percentage:50}]},{id:4,name:"IDE",panes:2,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2510","\u25021 \u2502 2 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:75}]},{id:5,name:"IDE+Term",panes:3,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2510","\u2502 \u2502 2 \u2502","\u25021 \u251C\u2500\u2500\u2500\u2500\u2524","\u2502 \u2502 3 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:75},{pane:1,horizontal:!1,percentage:50}]},{id:6,name:"Triple",panes:3,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u252C\u2500\u2500\u2510","\u25021 \u25022 \u25023 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2534\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:66},{pane:1,horizontal:!0,percentage:50}]},{id:7,name:"IDE+Side",panes:3,preview:["\u250C\u2500\u252C\u2500\u2500\u252C\u2500\u2510","\u25021\u25022 \u25023\u2502","\u2514\u2500\u2534\u2500\u2500\u2534\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:80},{pane:1,horizontal:!0,percentage:25}]},{id:8,name:"Quad",panes:4,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2510","\u25021 \u25022 \u2502","\u251C\u2500\u2500\u253C\u2500\u2500\u2524","\u25023 \u25024 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:50},{pane:0,horizontal:!1,percentage:50},{pane:1,horizontal:!1,percentage:50}]},{id:9,name:"IDE Pro",panes:4,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2510","\u2502 \u2502 2 \u2502","\u25021 \u251C\u2500\u2500\u252C\u2500\u2500\u2524","\u2502 \u2502 3\u25024 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2534\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:75},{pane:1,horizontal:!1,percentage:40},{pane:2,horizontal:!0,percentage:50}]}];function Q2(n,l,c){let f=Hc.find(D=>D.id===c);if(!f||f.splits.length===0)return;let p=`'${n.replace(/'/g,"'\\''")}':${l}`,m=0;try{let D=ti("tmux show-option -g pane-base-index",{encoding:"utf-8"}).trim();m=parseInt(D.split(" ").pop()||"0",10)}catch{}for(let D of f.splits){let v=D.horizontal?"-h":"-v",x=`${p}.${m+D.pane}`;ti(`tmux split-window -t ${x} ${v} -p ${D.percentage}`,{stdio:"pipe"})}}function h2(n){let l=new Date(n*1e3),c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],f=l.getHours().toString().padStart(2,"0"),E=l.getMinutes().toString().padStart(2,"0");return`${c[l.getMonth()]} ${l.getDate()} ${f}:${E}`}var $=Zt(eh(),1);function MF({interactive:n,onSelect:l,onCreate:c,onKill:f,onRename:E,onDetach:p}){let{exit:m}=ZQ(),[D,v]=(0,_u.useState)(WQ),[x,H]=(0,_u.useState)(0),[K,N]=(0,_u.useState)("list"),[L,X]=(0,_u.useState)(""),[q,J]=(0,_u.useState)(""),[Qt,ee]=(0,_u.useState)("name"),[Ht,It]=(0,_u.useState)(""),[Xt,He]=(0,_u.useState)(null),[Tt,Mt]=(0,_u.useState)([]),[dt,Ot]=(0,_u.useState)(0),[ue,yt]=(0,_u.useState)("list"),[$e,we]=(0,_u.useState)(0),gt=()=>{let st=WQ();v(st),H(nt=>Math.min(nt,Math.max(0,st.length-1)))},xt=()=>{if(!Xt)return;let st=$Q(Xt.name);Mt(st),Ot(nt=>Math.min(nt,Math.max(0,st.length-1)))};if(n&&VQ((st,nt)=>{if(K==="new"){if(nt.escape){N("list"),X(""),J(""),It("");return}if(nt.tab){ee(ht=>ht==="name"?"path":"name");return}if(nt.return){if(!L.trim()){It("Session name is required");return}let ht=(q||process.cwd()).replace(/^~/,process.env.HOME||"~");c?.(L.trim(),ht),m();return}if(nt.backspace||nt.delete){Qt==="name"?X(ht=>ht.slice(0,-1)):J(ht=>ht.slice(0,-1)),It("");return}st&&!nt.ctrl&&!nt.meta&&(Qt==="name"?X(ht=>ht+st):J(ht=>ht+st),It(""));return}if(K==="rename"){if(nt.escape){N("list"),X(""),It("");return}if(nt.return){if(!L.trim()){It("Name cannot be empty");return}E?.(D[x].name,L.trim()),gt(),N("list"),X(""),It("");return}if(nt.backspace||nt.delete){X(ht=>ht.slice(0,-1)),It("");return}st&&!nt.ctrl&&!nt.meta&&(X(ht=>ht+st),It(""));return}if(K==="confirm-kill"){if(nt.escape||st==="n"){N("list");return}(st==="y"||nt.return)&&(f?.(D[x].name),gt(),N("list"));return}if(K==="config"){if(ue==="new"){if(nt.escape){yt("list"),X(""),It("");return}if(nt.return){if(!L.trim()){It("Window name is required");return}try{p2(Xt.name,L.trim(),Xt.path)}catch(Ae){It(Ae.message);return}xt(),yt("list"),X(""),It("");return}if(nt.backspace||nt.delete){X(Ae=>Ae.slice(0,-1)),It("");return}st&&!nt.ctrl&&!nt.meta&&(X(Ae=>Ae+st),It(""));return}if(ue==="rename"){if(nt.escape){yt("list"),X(""),It("");return}if(nt.return){if(!L.trim()){It("Name cannot be empty");return}try{I2(Xt.name,Tt[dt].index,L.trim())}catch(Ae){It(Ae.message);return}xt(),yt("list"),X(""),It("");return}if(nt.backspace||nt.delete){X(Ae=>Ae.slice(0,-1)),It("");return}st&&!nt.ctrl&&!nt.meta&&(X(Ae=>Ae+st),It(""));return}if(ue==="confirm-delete"){if(nt.escape||st==="n"){yt("list");return}if(st==="y"||nt.return){try{m2(Xt.name,Tt[dt].index)}catch(Ae){It(Ae.message),yt("list");return}xt(),yt("list")}return}if(ue==="init-panes"){if(nt.escape){yt("list"),It("");return}if(nt.return){try{Q2(Xt.name,Tt[dt].index,Hc[$e].id)}catch(Ae){It(Ae.message);return}xt(),yt("list");return}nt.upArrow?we(Ae=>(Ae-1+Hc.length)%Hc.length):nt.downArrow&&we(Ae=>(Ae+1)%Hc.length);return}if(nt.escape){gt(),N("list"),He(null);return}if(st==="n"){yt("new"),X(""),It("");return}if(st==="r"&&Tt.length>0){yt("rename"),X(Tt[dt].name),It("");return}if(st==="d"&&Tt.length>0){yt("confirm-delete");return}let ht=Tt.length>0&&Tt[dt].panes===1&&!Tt[dt].active;if(st==="i"&&ht){we(0),yt("init-panes"),It("");return}nt.upArrow?Ot(Ae=>(Ae-1+Tt.length)%Tt.length):nt.downArrow&&Ot(Ae=>(Ae+1)%Tt.length);return}if(st==="q"){m();return}if(st==="n"){N("new"),ee("name"),X(""),J(""),It("");return}if(st==="r"&&D.length>0){N("rename"),X(D[x].name),It("");return}if(st==="x"&&D.length>0){p?.(D[x].name),gt();return}if(st==="d"&&D.length>0){N("confirm-kill");return}if(st==="c"&&D.length>0){let ht=D[x];He(ht),Mt($Q(ht.name)),Ot(0),yt("list"),It(""),N("config");return}nt.upArrow?H(ht=>(ht-1+D.length)%D.length):nt.downArrow?H(ht=>(ht+1)%D.length):nt.return&&D.length>0&&(l?.(D[x]),m())}),K==="new")return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,$.jsxs)(ct,{children:[" ","new session"]})]}),(0,$.jsxs)(Lt,{marginBottom:1,flexDirection:"column",children:[(0,$.jsxs)(Lt,{children:[(0,$.jsx)(ct,{color:Qt==="name"?"cyan":"white",bold:Qt==="name",children:"Name: "}),(0,$.jsx)(ct,{color:Qt==="name"?"cyan":"white",children:L}),Qt==="name"&&(0,$.jsx)(ct,{backgroundColor:"cyan",children:" "})]}),(0,$.jsxs)(Lt,{children:[(0,$.jsx)(ct,{color:Qt==="path"?"cyan":"white",bold:Qt==="path",children:"Path: "}),(0,$.jsx)(ct,{color:Qt==="path"?"cyan":"white",children:q}),Qt==="path"&&(0,$.jsx)(ct,{backgroundColor:"cyan",children:" "})]})]}),Ht&&(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{color:"red",children:Ht})}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"tab switch | \u21B5 create | esc cancel"})})]});if(K==="rename")return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,$.jsxs)(ct,{children:[" ","rename session"]})]}),(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{children:"New name: "}),(0,$.jsx)(ct,{color:"cyan",children:L}),(0,$.jsx)(ct,{backgroundColor:"cyan",children:" "})]}),Ht&&(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{color:"red",children:Ht})}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"\u21B5 confirm | esc cancel"})})]});if(K==="confirm-kill"&&D.length>0){let st=D[x];return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"red",children:" \u26A0 delete "})}),(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{children:"Kill session "}),(0,$.jsx)(ct,{bold:!0,color:"red",children:st.name}),(0,$.jsx)(ct,{children:"?"})]}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"y confirm | n/esc cancel"})})]})}if(K==="config"&&Xt){if(ue==="new")return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,$.jsxs)(ct,{children:[" ","new window"]})]}),(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{children:"Name: "}),(0,$.jsx)(ct,{color:"cyan",children:L}),(0,$.jsx)(ct,{backgroundColor:"cyan",children:" "})]}),Ht&&(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{color:"red",children:Ht})}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"\u21B5 create | esc cancel"})})]});if(ue==="rename")return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,$.jsxs)(ct,{children:[" ","rename window"]})]}),(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{children:"New name: "}),(0,$.jsx)(ct,{color:"cyan",children:L}),(0,$.jsx)(ct,{backgroundColor:"cyan",children:" "})]}),Ht&&(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{color:"red",children:Ht})}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"\u21B5 confirm | esc cancel"})})]});if(ue==="confirm-delete"&&Tt.length>0){let nt=Tt[dt];return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsx)(Lt,{marginBottom:1,children:(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"red",children:" \u26A0 delete "})}),(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{children:"Delete window "}),(0,$.jsx)(ct,{bold:!0,color:"red",children:nt.name}),(0,$.jsx)(ct,{children:"?"})]}),(0,$.jsx)(Lt,{children:(0,$.jsx)(ct,{dimColor:!0,children:"y confirm | n/esc cancel"})})]})}if(ue==="list")return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,$.jsxs)(ct,{children:[" ",Xt.name]}),(0,$.jsxs)(ct,{dimColor:!0,children:[" windows (",Tt.length,")"]})]}),Tt.length===0?(0,$.jsx)(ct,{dimColor:!0,children:"No windows found"}):Tt.map((nt,ht)=>(0,$.jsxs)(Lt,{children:[(0,$.jsx)(ct,{children:ht===dt?"\u25B8 ":" "}),(0,$.jsx)(ct,{bold:!0,color:ht===dt?"cyan":nt.active?"green":"white",children:nt.name.padEnd(20)}),(0,$.jsxs)(ct,{dimColor:!0,children:[nt.panes," pane",nt.panes!==1?"s":""]}),(0,$.jsx)(ct,{color:"yellow",children:nt.active?" active":""})]},nt.index)),n&&(0,$.jsxs)(Lt,{marginTop:1,children:[(0,$.jsx)(ct,{dimColor:!0,children:"\u2191\u2193 select | "}),(0,$.jsx)(ct,{color:"green",bold:!0,children:"n"}),(0,$.jsx)(ct,{dimColor:!0,children:" new | "}),(0,$.jsx)(ct,{color:"yellow",bold:!0,children:"r"}),(0,$.jsx)(ct,{dimColor:!0,children:" rename | "}),(0,$.jsx)(ct,{color:"red",bold:!0,children:"d"}),(0,$.jsx)(ct,{dimColor:!0,children:" delete | "}),Tt.length>0&&Tt[dt].panes===1&&!Tt[dt].active&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ct,{color:"cyan",bold:!0,children:"i"}),(0,$.jsx)(ct,{dimColor:!0,children:" init panes | "})]}),(0,$.jsx)(ct,{dimColor:!0,children:"esc back"})]})]});let st=Hc[$e];return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,$.jsxs)(ct,{children:[" ",Tt[dt]?.name]}),(0,$.jsx)(ct,{dimColor:!0,children:" init panes"})]}),Hc.map((nt,ht)=>(0,$.jsxs)(Lt,{children:[(0,$.jsx)(ct,{children:ht===$e?"\u25B8 ":" "}),(0,$.jsx)(ct,{bold:!0,color:ht===$e?"cyan":"white",children:`${nt.id}. ${nt.name.padEnd(12)}`}),(0,$.jsx)(ct,{dimColor:!0,children:`${nt.panes} pane${nt.panes!==1?"s":""}`})]},nt.id)),(0,$.jsxs)(Lt,{marginTop:1,flexDirection:"column",children:[(0,$.jsx)(ct,{dimColor:!0,children:"Preview:"}),st.preview.map((nt,ht)=>(0,$.jsx)(ct,{color:"cyan",children:nt},ht))]}),Ht&&(0,$.jsx)(Lt,{marginTop:1,children:(0,$.jsx)(ct,{color:"red",children:Ht})}),n&&(0,$.jsx)(Lt,{marginTop:1,children:(0,$.jsx)(ct,{dimColor:!0,children:"\u2191\u2193 select | \u21B5 apply | esc cancel"})})]})}return(0,$.jsxs)(Lt,{flexDirection:"column",paddingX:1,children:[(0,$.jsxs)(Lt,{marginBottom:1,children:[(0,$.jsx)(ct,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,$.jsxs)(ct,{dimColor:!0,children:[" ","tmux sessions (",D.length,")"]})]}),D.length===0?(0,$.jsx)(ct,{dimColor:!0,children:"No tmux sessions found"}):D.map((st,nt)=>(0,$.jsxs)(Lt,{flexDirection:"column",marginBottom:1,children:[(0,$.jsxs)(Lt,{children:[(0,$.jsx)(ct,{children:nt===x?"\u25B8 ":" "}),(0,$.jsx)(ct,{bold:!0,color:nt===x?"cyan":st.attached?"green":"white",children:st.name.padEnd(18)}),(0,$.jsxs)(ct,{dimColor:!0,children:[st.windows," win",st.windows!==1?"s":""]}),(0,$.jsx)(ct,{color:"yellow",children:st.attached?" attached ":" "}),(0,$.jsx)(ct,{dimColor:!0,children:h2(st.created)})]}),st.path&&(0,$.jsxs)(ct,{dimColor:!0,children:[" ",st.path.replace(process.env.HOME||"","~")]})]},st.sessionId)),n&&(0,$.jsxs)(Lt,{marginTop:1,children:[(0,$.jsx)(ct,{dimColor:!0,children:"\u2191\u2193 select | \u21B5 attach | "}),(0,$.jsx)(ct,{color:"green",bold:!0,children:"n"}),(0,$.jsx)(ct,{dimColor:!0,children:" new | "}),(0,$.jsx)(ct,{color:"yellow",bold:!0,children:"r"}),(0,$.jsx)(ct,{dimColor:!0,children:" rename | "}),(0,$.jsx)(ct,{color:"blue",bold:!0,children:"x"}),(0,$.jsx)(ct,{dimColor:!0,children:" detach | "}),(0,$.jsx)(ct,{color:"red",bold:!0,children:"d"}),(0,$.jsx)(ct,{dimColor:!0,children:" delete | "}),(0,$.jsx)(ct,{color:"magenta",bold:!0,children:"c"}),(0,$.jsx)(ct,{dimColor:!0,children:" config | "}),(0,$.jsx)(ct,{dimColor:!0,children:"q quit"})]})]})}function Ah({onSelect:n,onCreate:l,onKill:c,onRename:f,onDetach:E}){return(0,$.jsx)(MF,{interactive:!!process.stdin.isTTY,onSelect:n,onCreate:l,onKill:c,onRename:f,onDetach:E})}function v2(n){process.stdout.write(`\x1B]0;[tmux] ${n}\x07`);let l=process.env.TMUX?`tmux switch-client -t ${n}`:`tmux attach-session -t ${n}`;bF(l,{stdio:"inherit"})}var R2=process.argv.slice(2);if(R2[0]==="init"||R2[0]==="-i"){let n=HF(process.cwd()),l=process.cwd();try{PQ(n,l),console.log(`${n} project has been added to tmuxtui`)}catch{console.error("Failed to create session. A session with the same name may already exist."),process.exit(1)}process.exit(0)}var Pg={session:null,newSession:null},GF=qQ(N2.default.createElement(Ah,{onSelect:n=>{Pg.session=n},onCreate:(n,l)=>{PQ(n,l),Pg.newSession=n},onKill:n=>{C2(n)},onRename:(n,l)=>{B2(n,l)},onDetach:n=>{d2(n)}}));await GF.waitUntilExit();try{Pg.session?v2(Pg.session.name):Pg.newSession&&v2(Pg.newSession)}catch{process.exit(1)}
|
|
291
291
|
/*! Bundled license information:
|
|
292
292
|
|
|
293
293
|
react/cjs/react.production.js:
|