win10 使用wezterm替代tmux

在windows系统下,没有直接的tmux替代品。wezterm作为一个可高度自定义配置的终端,可以一定程度替代tmux,满足我在windows系统下替换tmux的需求。

配置wezterm,使其快捷键风格接近tmux。快捷键配置如下。基于该配置wezterm.lua,额外增加了更多的tmux风格的快捷键配置。将该配置放在~/.config/wezterm/wezterm.lua文件中

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 = {},
}
相关推荐
医学影像处理10 天前
tmux旧版本配置鼠标滑动页面| tmux运行时如何让新的配置文件生效
centos·计算机外设·tmux
ShCDNay1 个月前
Tmux常用操作--云GPU版
linux·ubuntu·tmux
极客先躯2 个月前
Win10鼠标总是频繁自动失去焦点-非常有效-重启之后立竿见影
计算机外设·win10·重启·频繁失去焦点·有效
我想学LINUX2 个月前
一文带你掌握 tmux -- 高效的终端复用工具
linux·嵌入式硬件·嵌入式·策略模式·tmux·tmux命令
Bruce_Liuxiaowei2 个月前
利用Python在Win10环境下实现拨号上网
开发语言·python·win10·拨号
zhaotun1232 个月前
ubuntu安装samba:win10直接访问ubuntu服务器的文件
ubuntu·win10·文件共享·samba
wkd_0073 个月前
【QT | 开发环境搭建】windows系统(Win10)安装 QT 5.12.12 开发环境
windows·qt·win10·qt开发环境·qt5.12.12
我就是个弟弟i3 个月前
Windows10企业版找不到微软商店以及微软商店打不开问题解决
windows·microsoft·win10·企业版·微软商店·microsoft store
抢囡囡糖未遂3 个月前
Win11如何找回熟悉的开始菜单、任务栏和右键菜单
win11·win10·win7·右键菜单·startallback·任务栏·开始菜单
NullPointerExpection3 个月前
win10安装wsl2(ubuntu20.04)并安装 TensorRT-8.6.1.6、cuda_11.6、cudnn
ubuntu·win10·wsl·tensorrt·cuda·cudnn·wsl2