在windows系统下,没有直接的tmux替代品。wezterm作为一个可高度自定义配置的终端,可以一定程度替代tmux,满足我在windows系统下替换tmux的需求。
配置wezterm,使其快捷键风格接近tmux。快捷键配置如下。基于该配置wezterm.lua,额外增加了更多的tmux风格的快捷键配置。将该配置放在~/.config/wezterm/wezterm.lua文件中
local wezterm = require("wezterm")
local act = wezterm.action
local config = {
audible_bell = "Disabled",
check_for_updates = false,
-- color_scheme = "Builtin Solarized Dark",
-- color_scheme = 'Monokai Pro (Gogh)',
color_scheme = 'Campbell (Gogh)',
inactive_pane_hsb = {
hue = 1.0,
saturation = 1.0,
brightness = 1.0,
},
font_size = 16.0,
launch_menu = {},
leader = { key="b", mods="CTRL" },
-- disable_default_key_bindings = true,
keys = {
-- Send "CTRL-A" to the terminal when pressing CTRL-A, CTRL-A
{ key = "b", mods = "LEADER|CTRL", action=wezterm.action{SendString="\x02"}},
{ key = "-", mods = "LEADER", action=wezterm.action{SplitVertical={domain="CurrentPaneDomain"}}},
{ key = "%", mods = "LEADER|SHIFT", action=wezterm.action{SplitHorizontal={domain="CurrentPaneDomain"}}},
{ key = "z", mods = "LEADER", action="TogglePaneZoomState" },
{ key = "c", mods = "LEADER", action=wezterm.action{SpawnTab="CurrentPaneDomain"}},
{ key = "h", mods = "LEADER", action=wezterm.action{ActivatePaneDirection="Left"}},
{ key = "j", mods = "LEADER", action=wezterm.action{ActivatePaneDirection="Down"}},
{ key = "k", mods = "LEADER", action=wezterm.action{ActivatePaneDirection="Up"}},
{ key = "l", mods = "LEADER", action=wezterm.action{ActivatePaneDirection="Right"}},
-- { key = "H", mods = "LEADER|SHIFT", action=wezterm.action{AdjustPaneSize={"Left", 5}}},
-- { key = "J", mods = "LEADER|SHIFT", action=wezterm.action{AdjustPaneSize={"Down", 5}}},
-- { key = "K", mods = "LEADER|SHIFT", action=wezterm.action{AdjustPaneSize={"Up", 5}}},
-- { key = "L", mods = "LEADER|SHIFT", action=wezterm.action{AdjustPaneSize={"Right", 5}}},
{ key = "1", mods = "LEADER", action=wezterm.action{ActivateTab=0}},
{ key = "2", mods = "LEADER", action=wezterm.action{ActivateTab=1}},
{ key = "3", mods = "LEADER", action=wezterm.action{ActivateTab=2}},
{ key = "4", mods = "LEADER", action=wezterm.action{ActivateTab=3}},
{ key = "5", mods = "LEADER", action=wezterm.action{ActivateTab=4}},
{ key = "6", mods = "LEADER", action=wezterm.action{ActivateTab=5}},
{ key = "7", mods = "LEADER", action=wezterm.action{ActivateTab=6}},
{ key = "8", mods = "LEADER", action=wezterm.action{ActivateTab=7}},
{ key = "9", mods = "LEADER", action=wezterm.action{ActivateTab=8}},
{ key = "&", mods = "LEADER|SHIFT", action=wezterm.action{CloseCurrentTab={confirm=true}}},
{ key = "x", mods = "LEADER", action=wezterm.action{CloseCurrentPane={confirm=true}}},
-- { key = "n", mods="SHIFT|CTRL", action="ToggleFullScreen" },
-- { key = "v", mods="SHIFT|CTRL", action=wezterm.action.PasteFrom 'Clipboard'},
--------------------------------------------------
-- custom config ---------------------------------
--------------------------------------------------
-- select window
-- paste shift+insert
-- { key="Insert", mods="SHIFT", action=wezterm.action.PasteFrom 'Clipboard'},
-- switch
-- { key = "]", mods = "LEADER", action = act.ActivateTabRelative(1) },
-- { key = "[", mods = "LEADER", action = act.ActivateTabRelative(-1) },
-- rename window
-- { key = ",", mods = "LEADER", action=act{SendString='[Console]::Title = "\x02"'}},
{
key = ",",
mods = "LEADER",
action = act.PromptInputLine {
description = 'Enter new name for tab',
action = wezterm.action_callback(function(window, _, line)
-- line will be `nil` if they hit escape without entering anything
-- An empty string if they just hit enter
-- Or the actual line of text they wrote
if line then
window:active_tab():set_title(line)
end
end),
},
},
-- rotate panes
{
mods = "LEADER",
key = "Space",
action = wezterm.action.RotatePanes "Clockwise"
},
-- show the pane selection mode, but have it swap the active and selected panes
-- { mods = 'LEADER', key = '0', action = wezterm.action.PaneSelect { mode = 'SwapWithActive', }, },
{ mods = 'LEADER', key = '0', action = wezterm.action.PaneSelect },
{ mods = "LEADER", key = "[", action = act.ActivateCopyMode },
{ mods = "LEADER", key = "]", action = act.PasteFrom 'Clipboard' },
{ mods = "LEADER", key = ":", action = act.ActivateCommandPalette },
{ mods = "LEADER", key = "Tab", action = act.ActivateLastTab },
{ mods = "LEADER", key = "/", action = act.Search 'CurrentSelectionOrEmptyString' },
-- Show the launcher in fuzzy selection mode and have it list all workspaces
-- and allow activating one.
{ mods = 'LEADER', key = 'w', action = wezterm.action.ShowTabNavigator },
{ mods = 'LEADER', key = 's', action = act.ShowLauncherArgs { flags = 'FUZZY|WORKSPACES', },
},
},
-- set_environment_variables = {},
}