kitty
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseKitty Remote Control Skill
Kitty远程控制技能
This skill empowers you to manage multiple concurrent processes (like servers, watchers, or long builds) using kitty's remote control feature directly from the tool.
BashSince you are running inside a kitty terminal, you can spawn new windows or tabs to handle these tasks without blocking your main communication channel.
借助该技能,你可以直接通过工具,利用kitty的远程控制功能管理多个并发进程(如服务器、监视器或长时间构建任务)。
Bash由于你正运行在kitty终端中,你可以创建新的窗口或标签页来处理这些任务,而不会阻塞主通信通道。
1. Verify Environment & Check Status
1. 验证环境并检查状态
First, verify you are running inside kitty with remote control enabled. You can try listing windows:
bash
kitten @ lsIf this fails, check if is set. Note that in some configurations it might be empty even if remote control is enabled (using default sockets).
$KITTY_LISTEN_ONbash
echo $KITTY_LISTEN_ONIf remote control is not enabled, the user should add to their or start kitty with .
allow_remote_control yeskitty.conf--allow-remote-control首先,验证你是否在已启用远程控制的kitty终端中运行。你可以尝试列出所有窗口:
bash
kitten @ ls如果该命令失败,请检查是否已设置环境变量。注意,在某些配置中,即使已启用远程控制(使用默认套接字),该变量也可能为空。
$KITTY_LISTEN_ONbash
echo $KITTY_LISTEN_ON如果未启用远程控制,用户需要在中添加配置,或者使用参数启动kitty。
kitty.confallow_remote_control yes--allow-remote-control2. Spawn a Background Process
2. 启动后台进程
To run a command (e.g., a dev server) in a way that persists and can be inspected:
-
Create a new window in the SAME tab as the agent (recommended): Useto ensure the new window stays with you.
$KITTY_WINDOW_IDbashWID=$(kitten @ launch --match "id:$KITTY_WINDOW_ID" --title "server-log" --keep-focus) echo "Created window with ID: $WID" -
Or create a new tab:bash
kitten @ launch --type=tab --title "server-log" --keep-focus -
Launch with a command directly: (Useif you want the window to stay open after the command finishes)
--holdbashkitten @ launch --title "server-log" --keep-focus --hold npm start
要以持久化且可查看的方式运行命令(例如开发服务器):
-
在当前会话的同一标签页中创建新窗口(推荐): 使用确保新窗口始终与当前会话关联。
$KITTY_WINDOW_IDbashWID=$(kitten @ launch --match "id:$KITTY_WINDOW_ID" --title "server-log" --keep-focus) echo "Created window with ID: $WID" -
或者创建新标签页:bash
kitten @ launch --type=tab --title "server-log" --keep-focus -
直接带命令启动: (如果希望命令执行完成后窗口保持打开状态,请使用参数)
--holdbashkitten @ launch --title "server-log" --keep-focus --hold npm start
3. Send Text/Commands to a Window
3. 向窗口发送文本/命令
Send keystrokes to a specific window. Use the window ID for precision, or matching for convenience.
Using ID (Reliable):
bash
kitten @ send-text --match "id:$WID" "npm start\n"Using Matching (Title):
Note: Use for Enter. In some shells, you may need to use or pipe to ensure the newline is interpreted correctly.
\n$'...'bash
kitten @ send-text --match "title:server-log" "npm start
"向指定窗口发送按键操作。可以使用窗口ID精准匹配,或者使用便捷匹配方式。
使用ID(可靠方式):
bash
kitten @ send-text --match "id:$WID" "npm start\n"使用匹配(标题):
注意:使用表示回车键。在某些shell中,你可能需要使用或管道来确保换行符被正确解析。
\n$'...'bash
kitten @ send-text --match "title:server-log" "npm start
"OR
或者
echo "npm start" | kitten @ send-text --match "title:server-log" --stdin
Or send to all windows:
```bash
kitten @ send-text --all "echo hello\n"echo "npm start" | kitten @ send-text --match "title:server-log" --stdin
也可以向所有窗口发送:
```bash
kitten @ send-text --all "echo hello\n"4. Inspect Output (Get Text from Window)
4. 查看输出(从窗口获取文本)
Get the current visible text from a window:
bash
kitten @ get-text --match "id:$WID"Get text including scrollback buffer:
bash
kitten @ get-text --match "title:server-log" --extent=allGet only the last command output (requires shell integration):
bash
kitten @ get-text --match "title:server-log" --extent=last_cmd_output获取窗口当前显示的文本:
bash
kitten @ get-text --match "id:$WID"获取包含回滚缓冲区的文本:
bash
kitten @ get-text --match "title:server-log" --extent=all仅获取最后一条命令的输出(需要shell集成):
bash
kitten @ get-text --match "title:server-log" --extent=last_cmd_output5. Focus or Bring Window to Front
5. 聚焦或前置窗口
Focus a specific window:
bash
kitten @ focus-window --match "id:$WID"Focus a specific tab:
bash
kitten @ focus-tab --match "title:server-log"聚焦指定窗口:
bash
kitten @ focus-window --match "id:$WID"聚焦指定标签页:
bash
kitten @ focus-tab --match "title:server-log"6. Interact with Processes
6. 与进程交互
Send Ctrl+C (Interrupt):
bash
kitten @ send-text --match "id:$WID" "\x03"Close a window:
bash
kitten @ close-window --match "id:$WID"Close a tab:
(Note: You can close a tab by matching its title or any window ID inside it)
bash
undefined发送Ctrl+C(中断信号):
bash
kitten @ send-text --match "id:$WID" "\x03"关闭窗口:
bash
kitten @ close-window --match "id:$WID"关闭标签页:
(注意:你可以通过匹配标签页标题或其中任意窗口的ID来关闭标签页)
bash
undefinedBy ID of a window inside the tab
通过标签页内某窗口的ID
kitten @ close-tab --match "id:$WID"
kitten @ close-tab --match "id:$WID"
By tab title
通过标签页标题
kitten @ close-tab --match "title:server-log"
undefinedkitten @ close-tab --match "title:server-log"
undefined7. Advanced: Window Matching
7. 进阶:窗口匹配
Kitty supports powerful matching expressions:
- - Match by window title
title:pattern - - Match by window ID
id:number - - Match by process ID
pid:number - - Match by current working directory
cwd:path - - Match by command line
cmdline:pattern - - Match the focused window
state:focused - - Match the active window
state:active
Combine with , , :
andornotbash
kitten @ focus-window --match "title:server and state:active"Kitty支持强大的匹配表达式:
- - 按窗口标题匹配
title:pattern - - 按窗口ID匹配
id:number - - 按进程ID匹配
pid:number - - 按当前工作目录匹配
cwd:path - - 按命令行匹配
cmdline:pattern - - 匹配当前聚焦的窗口
state:focused - - 匹配当前活动的窗口
state:active
可以结合、、使用:
andornotbash
kitten @ focus-window --match "title:server and state:active"8. Get Window/Tab Information
8. 获取窗口/标签页信息
List all OS windows, tabs, and windows as JSON:
bash
kitten @ lsGet current focused window ID:
bash
kitten @ ls | jq -r '.[].tabs[] | select(.is_focused) | .windows[] | select(.is_focused) | .id'Parse for specific info:
bash
kitten @ ls | jq '.[].tabs[].windows[] | {id, title, cmdline}'以JSON格式列出所有系统窗口、标签页和终端窗口:
bash
kitten @ ls获取当前聚焦窗口的ID:
bash
kitten @ ls | jq -r '.[].tabs[] | select(.is_focused) | .windows[] | select(.is_focused) | .id'解析特定信息:
bash
kitten @ ls | jq '.[].tabs[].windows[] | {id, title, cmdline}'Summary of Pattern
模式总结
- - Create window and save ID
WID=$(kitten @ launch --title "NAME" --keep-focus [CMD]) - - Send command reliably
kitten @ send-text --match "id:$WID" "CMD\n" - - Read output
kitten @ get-text --match "id:$WID" - - Cleanup
kitten @ close-window --match "id:$WID"
- - 创建窗口并保存ID
WID=$(kitten @ launch --title "NAME" --keep-focus [CMD]) - - 可靠地发送命令
kitten @ send-text --match "id:$WID" "CMD\n" - - 读取输出
kitten @ get-text --match "id:$WID" - - 清理资源
kitten @ close-window --match "id:$WID"
Common Remote Control Commands
常用远程控制命令
| Command | Description |
|---|---|
| List all windows/tabs |
| Create new window/tab |
| Send text to window |
| Get text from window |
| Focus a window |
| Focus a tab |
| Close a window |
| Close a tab |
| Send signal to process |
| Change tab title |
| Change terminal colors |
| 命令 | 描述 |
|---|---|
| 列出所有窗口/标签页 |
| 创建新窗口/标签页 |
| 向窗口发送文本 |
| 从窗口获取文本 |
| 聚焦窗口 |
| 聚焦标签页 |
| 关闭窗口 |
| 关闭标签页 |
| 向进程发送信号 |
| 修改标签页标题 |
| 修改终端颜色 |