Skip to content

Commit 1ae5a9e

Browse files
committed
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
1 parent 2a7bb18 commit 1ae5a9e

File tree

5 files changed

+11
-0
lines changed

5 files changed

+11
-0
lines changed

app/commands.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const commands: Record<string, (focusedWindow?: BrowserWindow) => void> = {
2727
'pane:close': (focusedWindow) => {
2828
focusedWindow?.rpc.emit('termgroup close req');
2929
},
30+
'tab:close': (focusedWindow) => {
31+
focusedWindow?.rpc.emit('tab close req');
32+
},
3033
'window:preferences': () => {
3134
void openConfig();
3235
},

app/keymaps/darwin.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"command+alt+left",
2828
"ctrl+shift+tab"
2929
],
30+
"tab:close": "command+w",
3031
"tab:jump:prefix": "command",
3132
"pane:next": "command+]",
3233
"pane:prev": "command+[",

app/keymaps/linux.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"ctrl+alt+left",
2626
"ctrl+shift+tab"
2727
],
28+
"tab:close": "ctrl+w",
2829
"tab:jump:prefix": "ctrl",
2930
"pane:next": "ctrl+pageup",
3031
"pane:prev": "ctrl+pagedown",

app/keymaps/win32.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"tab:prev": [
2323
"ctrl+shift+tab"
2424
],
25+
"tab:close": "ctrl+w",
2526
"tab:jump:prefix": "ctrl",
2627
"pane:next": "ctrl+pageup",
2728
"pane:prev": "ctrl+pagedown",

lib/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {configOptions} from '../typings/config';
1010
import {loadConfig, reloadConfig} from './actions/config';
1111
import init from './actions/index';
1212
import {addNotificationMessage} from './actions/notifications';
13+
import * as headerActions from './actions/header';
1314
import * as sessionActions from './actions/sessions';
1415
import * as termGroupActions from './actions/term-groups';
1516
import * as uiActions from './actions/ui';
@@ -97,6 +98,10 @@ rpc.on('termgroup close req', () => {
9798
store_.dispatch(termGroupActions.exitActiveTermGroup());
9899
});
99100

101+
rpc.on('tab close req', () => {
102+
store_.dispatch(headerActions.closeTab(store_.getState().sessions.activeUid));
103+
});
104+
100105
rpc.on('session clear req', () => {
101106
store_.dispatch(sessionActions.clearActiveSession());
102107
});

0 commit comments

Comments
 (0)