From 6ef1105a6b6a4c11b5b4d3e1ec2d35326c954dfb Mon Sep 17 00:00:00 2001 From: nKOxxx Date: Wed, 4 Mar 2026 18:09:13 +0400 Subject: [PATCH] feat: add tab:close keyboard shortcut Add Ctrl+W (Linux/Windows) and Cmd+W (Mac) shortcuts to close tabs. Changes: - Add tab:close command to app/commands.ts - Add keybinding to all platform keymaps (darwin, linux, win32) - Add RPC handler in lib/index.tsx to close active tab Closes #3548 --- app/commands.ts | 3 +++ app/keymaps/darwin.json | 1 + app/keymaps/linux.json | 1 + app/keymaps/win32.json | 1 + lib/index.tsx | 5 +++++ 5 files changed, 11 insertions(+) diff --git a/app/commands.ts b/app/commands.ts index 469a5a3d7f2c..e3f9f5b0a53a 100644 --- a/app/commands.ts +++ b/app/commands.ts @@ -27,6 +27,9 @@ const commands: Record void> = { 'pane:close': (focusedWindow) => { focusedWindow?.rpc.emit('termgroup close req'); }, + 'tab:close': (focusedWindow) => { + focusedWindow?.rpc.emit('tab close req'); + }, 'window:preferences': () => { void openConfig(); }, diff --git a/app/keymaps/darwin.json b/app/keymaps/darwin.json index 30f0f2763028..fd4ee5088064 100644 --- a/app/keymaps/darwin.json +++ b/app/keymaps/darwin.json @@ -27,6 +27,7 @@ "command+alt+left", "ctrl+shift+tab" ], + "tab:close": "command+w", "tab:jump:prefix": "command", "pane:next": "command+]", "pane:prev": "command+[", diff --git a/app/keymaps/linux.json b/app/keymaps/linux.json index da66d671d7f3..9a5679137460 100644 --- a/app/keymaps/linux.json +++ b/app/keymaps/linux.json @@ -25,6 +25,7 @@ "ctrl+alt+left", "ctrl+shift+tab" ], + "tab:close": "ctrl+w", "tab:jump:prefix": "ctrl", "pane:next": "ctrl+pageup", "pane:prev": "ctrl+pagedown", diff --git a/app/keymaps/win32.json b/app/keymaps/win32.json index 8e7b19134c49..9df240086e2c 100644 --- a/app/keymaps/win32.json +++ b/app/keymaps/win32.json @@ -22,6 +22,7 @@ "tab:prev": [ "ctrl+shift+tab" ], + "tab:close": "ctrl+w", "tab:jump:prefix": "ctrl", "pane:next": "ctrl+pageup", "pane:prev": "ctrl+pagedown", diff --git a/lib/index.tsx b/lib/index.tsx index 3d62015e8b0c..20b1d8af7992 100644 --- a/lib/index.tsx +++ b/lib/index.tsx @@ -10,6 +10,7 @@ import type {configOptions} from '../typings/config'; import {loadConfig, reloadConfig} from './actions/config'; import init from './actions/index'; import {addNotificationMessage} from './actions/notifications'; +import * as headerActions from './actions/header'; import * as sessionActions from './actions/sessions'; import * as termGroupActions from './actions/term-groups'; import * as uiActions from './actions/ui'; @@ -97,6 +98,10 @@ rpc.on('termgroup close req', () => { store_.dispatch(termGroupActions.exitActiveTermGroup()); }); +rpc.on('tab close req', () => { + store_.dispatch(headerActions.closeTab(store_.getState().sessions.activeUid)); +}); + rpc.on('session clear req', () => { store_.dispatch(sessionActions.clearActiveSession()); });